public async Task <IActionResult> Change([FromForm] ProfileChangeRequest request, [FromServices] ProfileManager profileManager) { await profileManager.ChangeProfile(request); return(Json(ApiResponse.Success(true))); }
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(); } }
public virtual async Task <ProfileChangeResponse> ProfileChangeAsync(Agent agent, ProfileChangeRequest profileChangeRequest) { return(await AgentConnect.ProfileChangeAsync(agent, profileChangeRequest)); }
public virtual ProfileChangeResponse ProfileChange(Agent agent, ProfileChangeRequest profileChangeRequest) { return(AgentConnect.ProfileChange(agent, profileChangeRequest)); }