Exemple #1
0
 ///<summary>
 ///Add row to DataBase
 /// </summary>
 /// <param name="tableStringParam">The entity to add</param>
 public void AddRecord(NumberValueEntity tableStringParam)
 {
     using (NumberValueContext nvc = new NumberValueContext())
     {
         try
         {
             nvc.NumberValue.Add(tableStringParam);
             nvc.SaveChanges();
         }
         catch (Exception ex)
         {
             throw new Exception(ex.Message);
         }
     }
 }
Exemple #2
0
 /// <summary>
 /// Delete row from DataBase
 /// </summary>
 /// <param name="idToDelete">Id to remove from table</param>
 public void DeleteRecord(int idToDelete)
 {
     using (NumberValueContext nvc = new NumberValueContext())
     {
         try
         {
             NumberValueEntity nve = nvc.NumberValue.Find(idToDelete);
             if (nve != null)
             {
                 nvc.NumberValue.Remove(nve);
             }
             else
             {
                 throw new Exception($"The row with id {idToDelete} didn't found");
             }
         }catch (Exception ex)
         {
             throw new Exception(ex.Message);
         }
     }
 }