コード例 #1
0
        public bool Update(Batch batch)
        {
            using (SmartSchoolDataModel dataModel = new SmartSchoolDataModel())
            {
                try
                {
                    var oldBatch = (from a in dataModel.Batches
                                    where a.Id == batch.Id
                                    select a).FirstOrDefault();

                    oldBatch.Title         = batch.Title;
                    oldBatch.BatchCapacity = batch.BatchCapacity;
                    oldBatch.TimeFrom      = batch.TimeFrom;
                    oldBatch.TimeTo        = batch.TimeTo;
                    oldBatch.IsActive      = batch.IsActive;
                    oldBatch.OnSunday      = batch.OnSunday;
                    oldBatch.OnMonday      = batch.OnMonday;
                    oldBatch.OnTuesday     = batch.OnTuesday;
                    oldBatch.OnWednesday   = batch.OnWednesday;
                    oldBatch.OnThursday    = batch.OnThursday;
                    oldBatch.OnFriday      = batch.OnFriday;
                    oldBatch.OnSaturday    = batch.OnSaturday;
                    oldBatch.Description   = batch.Description;

                    dataModel.SaveChanges();
                    return(true);
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }
        }
コード例 #2
0
 public int Insert(Batch batch)
 {
     using (SmartSchoolDataModel dataModel = new SmartSchoolDataModel())
     {
         dataModel.Batches.Add(batch);
         dataModel.SaveChanges();
         return(batch.Id);
     }
 }
コード例 #3
0
 public int Insert(FeesDetail fees)
 {
     using (SmartSchoolDataModel dataModel = new SmartSchoolDataModel())
     {
         try
         {
             dataModel.FeesDetails.Add(fees);
             dataModel.SaveChanges();
             return(fees.Id);
         }
         catch (Exception ex)
         {
             return(0);
         }
     }
 }