public ProductTypeOut Create(ProductTypeIn pTypeIn) { var pType = MapHelper.Map <ProductTypeIn, ProductType>(pTypeIn); ffContext.ProductTypes.Add(pType); ffContext.SaveChanges(); return(MapHelper.Map <ProductType, ProductTypeOut>(pType)); }
public ProductTypeOut Update(string id, ProductTypeIn pTypeIn) { var pType = MapHelper.Map <ProductTypeIn, ProductType>(pTypeIn); pType.Id = id; ffContext.ProductTypes.Update(pType); ffContext.SaveChanges(); return(MapHelper.Map <ProductType, ProductTypeOut>(pType)); }
public IActionResult Update([FromBody] ProductTypeIn pTypeIn, string id) { try { var pTypeOut = productTypeService.Update(id, pTypeIn); return(Json(pTypeOut)); } catch (ArgumentException ex) { Response.StatusCode = 403; var msg = new JsonMessage("Исключение на свойстве: " + ex.Message, ""); return(Json(msg)); } }