예제 #1
0
        public Sponsor GetManufacturerByID(int id, string lang = "en")
        {
            Sponsor sponsor = databasePlaceholder.Get(id, lang);

            if (sponsor == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return(sponsor);
        }
예제 #2
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());
        }
 public IHttpActionResult Get(int id)
 {
     return(Json(sponsorRepository.Get(id)));
 }