public virtual void Delete(RoomViewModel room, ModelStateDictionary modelState) { var entity = room.ToEntity(); db.Rooms.Attach(entity); // TODO: here should verify the room id is not in the meeting tables db.Rooms.Remove(entity); db.SaveChanges(); }
public virtual void Insert(RoomViewModel room, ModelStateDictionary modelState) { if (ValidateModel(room, modelState)) { if (string.IsNullOrEmpty(room.Text)) { room.Text = ""; } if (room.Value < 0) { room.Value = 100; } var entity = room.ToEntity(); db.Rooms.Add(entity); db.SaveChanges(); room.ID = entity.ID; } }
public virtual void Update(RoomViewModel room, ModelStateDictionary modelState) { if (ValidateModel(room, modelState)) { if (string.IsNullOrEmpty(room.Text)) { room.Text = ""; } if (room.Value < 0) { room.Value = 100; } var entity = room.ToEntity(); db.Rooms.Attach(entity); db.Entry(entity).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); UpdateAttendeeRoomDetail(entity); } }