Example #1
0
        public void EditRoom(RoomDataModel room)
        {
            var entity = context.Rooms.SingleOrDefault(e => e.Id == room.Id);

            SetEntityFromRoom(entity, room);
            context.SaveChanges();
        }
Example #2
0
        private Room RoomToEntity(RoomDataModel room)
        {
            var entity = new Room();

            SetEntityFromRoom(entity, room);
            return(entity);
        }
Example #3
0
        public int AddRoom(RoomDataModel room)
        {
            var result = context.Rooms.Add(RoomToEntity(room));

            context.SaveChanges();

            return(result.Entity.Id);
        }
Example #4
0
 private void SetEntityFromRoom(Room entity, RoomDataModel room)
 {
     entity.Name        = room.Name;
     entity.Description = room.Description;
 }