Exemplo n.º 1
0
 public int SaveStandardPrices(StandardPrices data)
 {
     try
     {
         if (data.Id == 0)
         {
             context.StandardPrices.Add(data);
         }
         else
         {
             var toUpdate = context.StandardPrices.FirstOrDefault(a => a.Id == data.Id);
             toUpdate.Currency     = data.Currency;
             toUpdate.Description  = data.Description;
             toUpdate.MaterialCode = data.MaterialCode;
             toUpdate.Plant        = data.Plant;
             toUpdate.PricePerUnit = data.PricePerUnit;
             toUpdate.Type         = data.Type;
         }
         context.SaveChanges();
         return(data.Id);
     }
     catch (Exception ex)
     {
         return(-1);
     }
 }
 public int Post([FromBody] StandardPrices data)
 {
     return(_repo.SaveStandardPrices(data));
 }