public ActionResult <Data.Models.Profile> Put([FromBody] UpdateProfileDTO request) { var command = new EditProfileCommand(_mapper.Map <Data.Models.Profile>(request)); var handler = _commandHandler.Build(command); return(Ok(handler.Execute())); }
public async Task <Result <PatientHeiProfile> > Handle(EditProfileCommand request, CancellationToken cancellationToken) { using (_unitOfWork) { try { PatientHeiProfile patientHeiProfile = _unitOfWork.Repository <PatientHeiProfile>().Get(x => x.PatientId == request.PatientHeiProfile.PatientId && x.PatientMasterVisitId == request.PatientHeiProfile.PatientMasterVisitId).FirstOrDefault(); if (patientHeiProfile != null) { patientHeiProfile.VisitDate = request.PatientHeiProfile.VisitDate; patientHeiProfile.VisitType = request.PatientHeiProfile.VisitType; } await _unitOfWork.Repository <PatientHeiProfile>().AddAsync(patientHeiProfile); await _unitOfWork.SaveAsync(); return(Result <PatientHeiProfile> .Valid(patientHeiProfile)); } catch (Exception e) { Log.Error(e.Message + " " + e.InnerException); return(Result <PatientHeiProfile> .Invalid(e.Message)); } } }
public ActionResult Edit(EditUserModel model) { var command = new EditProfileCommand(UserInfo.Id, model.Brag, model.Latitude, model.Longitude); ExecuteCommand(command); TempData[ViewDataKeys.Message] = new SuccessMessage(Resources.ProfileUpdateSuccess); return(RedirectToAction("Profile")); }
public ActionResult EditProfile(EditProfileCommand editProfileCommand) { User user = this._accountRepository.FindByEmail(editProfileCommand.Email); user.DateOfBirth = editProfileCommand.DateOfBirth; user.FirsName = editProfileCommand.FirstName; user.LastName = editProfileCommand.LastName; return(View(editProfileCommand)); }
public ActionResult Edit(EditUserModel model) { var command = new EditProfileCommand(UserInfo.Id, model.Brag, model.Latitude, model.Longitude); ExecuteCommand(command); TempData[ViewDataKeys.Message] = new SuccessMessage(Resources.ProfileUpdateSuccess); return RedirectToAction("Profile"); }
public async Task <IActionResult> Put([FromBody] EditProfileCommand editProfileCommand) { var response = await _mediator.Send(editProfileCommand, Request.HttpContext.RequestAborted); if (response.IsValid) { return(Ok(response)); } return(BadRequest(response)); }
public AccountSettingsController( UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, ILogger <AccountSettingsController> logger, ApplicationDbContext context, IHostingEnvironment environment) { _userManager = userManager; _signInManager = signInManager; _logger = logger; _editProfileCommand = new EditProfileCommand(context, environment); }
public async Task ShouldThrowValidationExceptionDuringProfileEditing(int testAge, string testNickname) { //arrange var loggedUser = await RunAsUserAsync("scott101@localhost", "Pa$$w0rd!"); var command = new EditProfileCommand() { Age = testAge, Nickname = testNickname }; //act //assert FluentActions.Invoking(() => SendAsync(command)).Should().ThrowAsync <Common.Exceptions.ValidationException>(); }
public async Task <OperationResult> Handle(EditProfileCommand request, CancellationToken cancellationToken) { var user = await _context.Users.SingleOrDefaultAsync(u => u.Id == request.User.Id); if (user == null) { return(OperationResult.Failed(ErrorMessageResource.NotFoundError, DisplayNameResource.User)); } user.FirstName = request.User.FirstName; user.LastName = request.User.LastName; if (await _context.SaveChangesAsync() < 0) { return(OperationResult.Failed(ErrorMessageResource.CommitError)); } return(OperationResult.Success()); }
public async Task <ActionResult <Unit> > Edit(EditProfileCommand command) { return(await Mediator.Send(command)); }
public async Task <IActionResult> EditProfile([FromForm] EditProfileCommand command) { var response = await _handler.Handler(command); return(response.Success ? Ok(response) : StatusCode(400, response)); }
public ICommandHandler <EditProfileCommand, Profile> Build(EditProfileCommand command) { return(new EditProfileCommandHandler(_service, command)); }