public async Task <IActionResult> AddPattern([FromBody] PatternAddForm json) { var photoName = await _photoService.SafePhoto(json.Photo); var id = _furnitureService.AddPattern(photoName, json); var response = _furnitureService.GetSingle <Material, MaterialResponse>(id); response.Photo = photoName; return(StatusCode(201, response)); }
public int AddPattern(string photoName, PatternAddForm pattern) { var id = AddOne <Pattern, PatternAddForm>(pattern, new List <string>() { nameof(PatternAddForm.Name) }); _context.PatternPhotos.Add(new PatternPhoto() { PatternId = id, Path = photoName }); if (_context.SaveChanges() == 0) { throw new HttpStatusCodeException(HttpStatusCode.InternalServerError, _localizer["Coud not add data"]); } return(id); }