public IActionResult ConfirmDeliveryManEmail(string userId, string code) { var deliveryMan = deliveryManService.GetDeliveryManByIdentityId(userId); if (!deliveryMan.HasValidatedEmail) { deliveryMan.HasValidatedEmail = true; deliveryManService.EditDeliveryMan(deliveryMan); return(View("ConfirmUserEmail")); } return(View("NotFound")); }
public async Task <IActionResult> EditDeliveryMan(DeliveryMenViewModel dvm, IFormFile file) { var deliveryMan = deliveryManService.GetDeliveryManById(dvm.DeliveryMan.Id); var deliveryManLocation = locationService.GetLocationById(dvm.DeliveryMan.Location.Id); deliveryMan.FirstName = dvm.DeliveryMan.FirstName; deliveryMan.LastName = dvm.DeliveryMan.LastName; deliveryMan.Phone = dvm.DeliveryMan.Phone; deliveryManLocation.Address = dvm.DeliveryMan.Location.Address; deliveryManLocation.City = dvm.DeliveryMan.Location.City; deliveryManLocation.ZipCode = dvm.DeliveryMan.Location.ZipCode; if (file != null) { //The picture has been changed //Upload the new picture var picturePath = FileUploader.UploadImage(file, "DeliveryMenPictures"); var pictureBytes = FileUploader.FileToBase64(picturePath); deliveryMan.PicturePath = picturePath; deliveryMan.ImageBase64 = pictureBytes; } if (deliveryMan.Email != dvm.DeliveryMan.Email) { //Email has been updated var user = await _userManager.FindByIdAsync(deliveryMan.IdentityId); if (user != null) { user.Email = dvm.DeliveryMan.Email; user.NormalizedEmail = dvm.DeliveryMan.Email.ToUpper(); user.UserName = dvm.DeliveryMan.Email; user.NormalizedUserName = dvm.DeliveryMan.Email.ToUpper(); deliveryMan.Email = dvm.DeliveryMan.Email; deliveryMan.HasValidatedEmail = true; await _userManager.UpdateAsync(user); } } deliveryMan.Location = deliveryManLocation; locationService.UpdateLocation(deliveryManLocation); deliveryManService.EditDeliveryMan(deliveryMan); TempData["Message"] = "Livreur modifié avec succès !"; return(RedirectToAction("AllDeliveryMen")); }
public ActionResult <DeliveryMan> SetDeliveryManPlayerId(DeliveryManForSettingPlayerIdDto deliveryManDto) { var deliveryMan = deliveryMenService.GetDeliveryManById(deliveryManDto.DeliveryManId); if (deliveryMan == null) { return(NotFound()); } if (deliveryMan.PlayerId == null || deliveryMan.PlayerId != deliveryManDto.PlayerId) { deliveryMan.PlayerId = deliveryManDto.PlayerId; deliveryMenService.EditDeliveryMan(deliveryMan); } return(Ok(deliveryMan)); }