public HttpResponseMessage Update([FromBody] UpdateColorDto colorDto)
 {
     return(Request.ExecuteProtectedAndWrapResult <UpdateColorDto, PartColorModel>(
                dto => ColorsService.UpdateColor(dto),
                ModelState, colorDto
                ));
 }
Esempio n. 2
0
        public PartColorModel UpdateColor(UpdateColorDto dto)
        {
            return(ProtectedExecute <UpdateColorDto, PartColorModel>(colorDto =>
            {
                AdminService.CheckActiveSuperAdmin(colorDto.SuperAdminSession);

                PartColorModel model = Mapper.Map <UpdateColorDto, PartColorModel>(colorDto);
                PartColorModel foundColor = ColorRepo.GetByName(model.Name);

                if (foundColor != null && foundColor.Id != model.Id)
                {
                    throw new ConflictException("Color name");
                }

                return ColorRepo.Update(model.Id, model);
            }, dto));
        }