Exemplo n.º 1
0
        public async Task <IActionResult> Change([FromForm] ProfileChangeRequest request,
                                                 [FromServices] ProfileManager profileManager)
        {
            await profileManager.ChangeProfile(request);

            return(Json(ApiResponse.Success(true)));
        }
Exemplo n.º 2
0
        public async Task ChangeProfile(ProfileChangeRequest request)
        {
            using (var ProfileRep = new Repository <PersonProfile>(_provider)) {
                var profile = await ProfileRep.Get(x => x.UniqueId == new Guid(request.UniqueId)).SingleAsync();

                profile.Phone   = request.Phone;
                profile.Address = request.Address;
                profile.City    = request.City;
                var avatarRep     = new Repository <ProfileAvatar>(ProfileRep);
                var profileAvatar = await avatarRep.Get(x => x.Profile == profile).FirstOrDefaultAsync();

                var isExistAvatar = true;
                if (profileAvatar == null)
                {
                    profileAvatar = new ProfileAvatar();
                    isExistAvatar = false;
                }

                if (request.Avatar != null)
                {
                    using (var memoryStream = new MemoryStream())
                    {
                        await request.Avatar.CopyToAsync(memoryStream);

                        profileAvatar.Avatar      = memoryStream.ToArray();
                        profileAvatar.ContentType = request.Avatar.ContentType;
                        profileAvatar.FileName    = request.Avatar.FileName;
                        profileAvatar.Profile     = profile;
                    }
                    if (!isExistAvatar)
                    {
                        await avatarRep.InsertAsync(profileAvatar);
                    }
                    else
                    {
                        await avatarRep.UpdateAsync(profileAvatar);
                    }
                }
                ProfileRep.Update(profile);
                ProfileRep.Commit();
            }
        }
Exemplo n.º 3
0
 public virtual async Task <ProfileChangeResponse> ProfileChangeAsync(Agent agent, ProfileChangeRequest profileChangeRequest)
 {
     return(await AgentConnect.ProfileChangeAsync(agent, profileChangeRequest));
 }
Exemplo n.º 4
0
 public virtual ProfileChangeResponse ProfileChange(Agent agent, ProfileChangeRequest profileChangeRequest)
 {
     return(AgentConnect.ProfileChange(agent, profileChangeRequest));
 }