コード例 #1
0
 public Offer SaveOffer(Offer record)
 {
     using (BM_DatabaseEntities db = new BM_DatabaseEntities())
     {
         db.Offers.Add(record);
         db.SaveChanges();
         return(record);
     }
 }
コード例 #2
0
 public void Delete(Service record)
 {
     using (BM_DatabaseEntities db = new BM_DatabaseEntities())
     {
         var service = db.Services.SingleOrDefault(s => s.Id == record.Id);
         db.Services.Remove(service);
         db.SaveChanges();
     }
 }
コード例 #3
0
 public Service Insert(Service record)
 {
     using (BM_DatabaseEntities db = new BM_DatabaseEntities())
     {
         db.Services.Add(record);
         db.SaveChanges();
         return(record);
     }
 }
コード例 #4
0
 public void DeleteTask(Task record)
 {
     using (BM_DatabaseEntities db = new BM_DatabaseEntities())
     {
         var task = db.Tasks.FirstOrDefault(t => t.Id == record.Id);
         db.Tasks.Attach(task);
         db.Tasks.Remove(task);
         db.SaveChanges();
     }
 }
コード例 #5
0
 public void Update(Service record)
 {
     using (BM_DatabaseEntities db = new BM_DatabaseEntities())
     {
         var service = db.Services.SingleOrDefault(s => s.Id == record.Id);
         service.Measure = record.Measure;
         service.Name    = record.Name;
         service.Price   = record.Price;
         db.SaveChanges();
     }
 }
コード例 #6
0
        public Task SaveTask(Task record)
        {
            using (BM_DatabaseEntities db = new BM_DatabaseEntities())
            {
                try
                {
                    db.Tasks.Add(record);
                    db.SaveChanges();
                }

                catch (DbEntityValidationException ee)
                {
                    foreach (var error in ee.EntityValidationErrors)
                    {
                        foreach (var thisError in error.ValidationErrors)
                        {
                            var errorMessage = thisError.ErrorMessage;
                        }
                    }
                }
                return(record);
            }
        }