Example #1
0
 public static List <Area> GetAreas(string AreaId)
 {
     using (BDMSEntities dbContext = new BDMSEntities())
     {
         try { return(dbContext.Areas.Any(x => x.AreaId.Equals(AreaId)) ? dbContext.Areas.Where(x => x.AreaId.Equals(AreaId)).ToList() : null); }
         catch (Exception ex)
         {
             throw;
         }
         finally { dbContext.Dispose(); }
     }
 }
Example #2
0
 public static List <Area> GetAreas()
 {
     using (BDMSEntities dbContext = new BDMSEntities())
     {
         try { return(dbContext.Areas != null ? dbContext.Areas.ToList() : null); }
         catch (Exception ex)
         {
             throw;
         }
         finally { dbContext.Dispose(); }
     }
 }
Example #3
0
 public static void InsertArea(Area area)
 {
     using (BDMSEntities dbContext = new BDMSEntities())
     {
         try
         {
             dbContext.Areas.Add(area);
             dbContext.SaveChanges();
         }
         catch (Exception ex)
         {
             throw;
         }
         finally { dbContext.Dispose(); }
     }
 }
Example #4
0
 public static void UpdateArea(Area updatedArea)
 {
     using (BDMSEntities dbContext = new BDMSEntities())
     {
         try
         {
             Area area = dbContext.Areas.FirstOrDefault(x => x.AreaId.Equals(updatedArea.AreaId));
             if (area != null)
             {
                 area = updatedArea;
                 dbContext.SaveChanges();
             }
         }
         catch (Exception ex)
         {
             throw;
         }
         finally { dbContext.Dispose(); }
     }
 }