Exemple #1
0
        public IActionResult Create(DTO.Room item)
        {
            var dalitem = new DAL.Room();

            dalitem.RoomId     = item.RoomId;
            dalitem.RoomNumber = item.RoomNumber;
            dalitem.Capacity   = item.Capacity;
            DAL.RoomManager.AddRoom(dalitem);
            return(Created("http://localhost:6544/api/rooms", item));
        }
Exemple #2
0
 public ActionResult <DTO.Room> GetById(int id)
 {
     DTO.Room dtoroom = new DTO.Room();
     dtoroom.Seats = new List <DTO.MovieEventSeat>();
     DAL.Room dalroom = DAL.RoomManager.GetRoomById(id);
     dtoroom.RoomId     = dalroom.RoomId;
     dtoroom.Capacity   = dalroom.Capacity;
     dtoroom.RoomNumber = dalroom.RoomNumber;
     dtoroom.Seats      = new List <DTO.MovieEventSeat>();
     foreach (var dalseat in dalroom.Seats)
     {
         DTO.MovieEventSeat s = new DTO.MovieEventSeat();
         s.SeatId     = dalseat.SeatId;
         s.RowNumber  = dalseat.RowNumber;
         s.SeatNumber = dalseat.SeatNumber;
         dtoroom.Seats.Add(s);
     }
     return(dtoroom);
 }
 /// <remarks>
 /// adds new Room entry to DB
 /// Used for development of app, to ensure uniform data in DB on all dev stations
 /// </remarks>
 public void addNew(string name, int seats, bool active)
 {
     _log.Trace("in addNew()");
     using (Keskus_baasEntities db = new Keskus_baasEntities())
     {
         DAL.Room room = new DAL.Room
         {
             Name = name,
             Seats = seats,
             Active = active
         };
         db.Rooms.Add(room);
         try
         {
             db.SaveChanges();
             //userlog registeres new db entry added event 
             _userlog.Trace(string.Format("New room added: {0}, {1}, {2}", room.Name, room.Seats, room.Active));
         }
         catch (Exception ex)
         {
             _log.Trace(string.Format("addNew() - An error occurred: '{0}'", ex));
         }
     }
 }