public OperationResult Edit(EditGuest command) { var operation = new OperationResult(); operation.IsSuccedded = false; var editItem = _guestRepository.Get(command.Id); if (editItem == null) { return(operation.Failed(ApplicationMessages.RecordNotFound)); } if (_guestRepository.Exist(x => x.FullName == command.FullName && x.Id != command.Id)) { return(operation.Failed(ApplicationMessages.DuplicatedRecord)); } var slug = command.FullName.Slugify(); var ImageFolderName = Tools.ToFolderName(this.GetType().Name); var ImagePath = $"{ImageFolderName}/{slug}"; var imageFileName = _fileUploader.Upload(command.Image, ImagePath); editItem.Edit(command.FullName, command.Tel, command.Email, imageFileName, command.ImageAlt, command.ImageTitle, command.GuestType, command.Coordinator); _guestRepository.SaveChanges(); return(operation.Succedded()); }
public JsonResult OnPostEdit(EditGuest command) { var result = _guestApplication.Edit(command); return(new JsonResult(result)); }