public JsonResult UpdateUnitOfMeasure([FromBody] List <UnitMeasureProductViewModel> data) { List <UnidadeMedidaProduto> results = DBUnitMeasureProduct.GetAll(); results.RemoveAll(x => data.Any(u => u.Code == x.Código && u.ProductNo == x.NºProduto)); results.ForEach(x => DBUnitMeasureProduct.Delete(x)); data.ForEach(x => { DBUnitMeasureProduct.Update(DBUnitMeasureProduct.ParseToDb(x)); }); return(Json(data)); }
public JsonResult CreateUnitOfMeasure([FromBody] UnitMeasureProductViewModel data) { string eReasonCode = ""; //Create new eReasonCode = DBUnitMeasureProduct.Create(DBUnitMeasureProduct.ParseToDb(data)) == null ? "101" : ""; if (String.IsNullOrEmpty(eReasonCode)) { return(Json(data)); } else { return(Json(eReasonCode)); } }