Esempio n. 1
0
 public void Activate(int fieldOfWaterId)
 {
     using (var context = new IdeaPoolEntities())
     {
         FieldOfWater fieldOfWater = context
                                     .FieldOfWaters
                                     .Where(x => x.Id == fieldOfWaterId)
                                     .Single();
         fieldOfWater.IsActive             = true;
         context.Entry(fieldOfWater).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Esempio n. 2
0
 public void Insert(FieldOfWaterDataObject fieldOfWater)
 {
     using (var context = new IdeaPoolEntities())
     {
         FieldOfWater other = context.FieldOfWaters.Where(x => x.Id == FIELDOFWATER_OTHER_ID).Single();
         context
         .FieldOfWaters
         .Add(new FieldOfWater
         {
             CreatedByUserId = fieldOfWater.CreatedByUserId,
             Name            = fieldOfWater.Name,
             Description     = fieldOfWater.Description,
             IsActive        = true,
             Order           = other.Order // set the order to last but one
         });
         // Increment the order of other field of water to last
         other.Order = other.Order + 1;
         context.Entry(other).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }