Exemplo n.º 1
0
 public string RemoveUnit_Of_Measurement(int id)
 {
     try
     {
         var item = Unit_Of_Measurements.FirstOrDefault(x => x.Unit_Of_MeasurementID == id);
         Unit_Of_Measurements.Remove(item);
         SaveChanges();
         return("Запись успешно удалена");
     }
     catch (Exception ex) { return(ex.Message); }
 }
Exemplo n.º 2
0
 public string AddUnit_Of_Measurement(string full_name, string short_name)
 {
     try
     {
         Unit_Of_Measurement unit_Of_ = new Unit_Of_Measurement
         {
             Full_Title  = full_name,
             Short_Title = short_name
         };
         Unit_Of_Measurements.Add(unit_Of_);
         SaveChanges();
         return("Запись успешно добавлена");
     }
     catch (Exception ex) { return(ex.Message); }
 }
Exemplo n.º 3
0
 public string EditUnit_Of_Measurement(int id, string full_name, string short_name)
 {
     try
     {
         var item = Unit_Of_Measurements.FirstOrDefault(x => x.Unit_Of_MeasurementID == id);
         if (item != null)
         {
             item.Full_Title  = full_name;
             item.Short_Title = short_name;
         }
         SaveChanges();
         return("Запись успешно отредактирована");
     }
     catch (Exception ex) { return(ex.Message); }
 }
Exemplo n.º 4
0
 public List <Unit_Of_Measurement> GetAllUnit_Of_Measurement() => Unit_Of_Measurements.ToList();