Exemplo n.º 1
0
        public OperationResult Edit(EditSponsor command)
        {
            var operation = new OperationResult();

            operation.IsSuccedded = false;
            var editItem = _sponsorRepository.Get(command.Id);

            if (editItem == null)
            {
                return(operation.Failed(ApplicationMessages.RecordNotFound));
            }
            if (_sponsorRepository.Exist(x => x.Name == command.Name && x.Id != command.Id))
            {
                return(operation.Failed(ApplicationMessages.DuplicatedRecord));
            }

            var ImageFolderName = Tools.ToFolderName(this.GetType().Name);
            var ImagePath       = $"{ImageFolderName}/{command.Name}";
            var imageFileName   = _fileUploader.Upload(command.Image, ImagePath);

            editItem.Edit(command.Name, command.Tel, imageFileName, command.ImageAlt, command.ImageTitle, command.IsVisible, command.Bio);
            _sponsorRepository.SaveChanges();
            return(operation.Succedded());
        }
Exemplo n.º 2
0
        public JsonResult OnPostEdit(EditSponsor command)
        {
            var result = _sponsorApplication.Edit(command);

            return(new JsonResult(result));
        }