IUserResource Interface |
Namespace: AskiaPortalCmn
The IUserResource type exposes the following members.
Name | Description | |
---|---|---|
![]() | FileName |
Indicates the name of the resource file.
|
![]() | Format |
Indicates the format of the resource (ex: image/URL)
|
![]() | Id |
Identifier of the user resource
|
![]() | IsModified |
Flag to indicates if the object
has been modified since his initialization.
|
![]() | UserId |
Identifier of the user associated with that resource
|
![]() | Value |
Get the resource.
|
Name | Description | |
---|---|---|
![]() | Reload |
Reload the resource using the current database
value.
|
![]() | Save |
Save the modification in the database
if the object has been modified.
|
![]() ![]() | SetImage |
Set the value of the resource as an image.
|
![]() ![]() | SetUrl |
Set the value of the resource as an URL.
|
Set the user avatar
var httpRequest = HttpContext.Current.Request; if (httpRequest.Files.Count != 1) { throw new Exception("No image or too many image found in the request. The request accept exactly 1 image file."); } var imageFile = httpRequest.Files[0]; var binaryReader = new BinaryReader(imageFile.InputStream); var bytes = b.ReadBytes(imageFile.ContentLength); var context = ContextFactory.CreateByLoginOrEmailAndPassword("login", "secret"); var user = context.User; var resource = user.Avatar; var result = resource.SetImage(imageFile.FileName, bytes); if (!result.Success) { throw result.Exception; }