public void DeleteItem(RoomInfo i)
 {
     using (IDataContext ctx = DataContext.Instance())
     {
         var rep = ctx.GetRepository<RoomInfo>();
         rep.Delete(i);
     }
 }
        public HttpResponseMessage CreateRoom(RoomInfo room)
        {
            try
            {
                room.CreatedByDate = DateTime.Now;
                room.CreatedByUserId = UserInfo.UserID;
                room.LastUpdatedByDate = DateTime.Now;
                room.LastUpdatedByUserId = UserInfo.UserID;

                RoomDataAccess.CreateItem(room);

                var savedRoom = RoomDataAccess.GetItems(room.CodeCampId).OrderByDescending(r => r.CreatedByDate).FirstOrDefault();

                var response = new ServiceResponse<RoomInfo> { Content = savedRoom };

                return Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson());
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE);
            }
        }
        public HttpResponseMessage UpdateRoom(RoomInfo room)
        {
            try
            {
                var originalRoom = RoomDataAccess.GetItem(room.RoomId, room.CodeCampId);
                var updatesToProcess = false;

                if (!string.Equals(originalRoom.RoomName, room.RoomName))
                {
                    originalRoom.RoomName = room.RoomName;
                    updatesToProcess = true;
                }

                if (!string.Equals(originalRoom.Description, room.Description))
                {
                    originalRoom.Description = room.Description;
                    updatesToProcess = true;
                }

                if (originalRoom.MaximumCapacity != room.MaximumCapacity)
                {
                    originalRoom.MaximumCapacity = room.MaximumCapacity;
                    updatesToProcess = true;
                }

                if (updatesToProcess)
                {
                    room.LastUpdatedByDate = DateTime.Now;
                    room.LastUpdatedByUserId = UserInfo.UserID;

                    RoomDataAccess.UpdateItem(room);
                }

                var savedRoom = RoomDataAccess.GetItem(room.RoomId, room.CodeCampId);

                var response = new ServiceResponse<RoomInfo> { Content = savedRoom };

                return Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson());
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE);
            }
        }
Exemple #4
0
 public void UpdateItem(RoomInfo i)
 {
     repo.UpdateItem(i);
 }
Exemple #5
0
 public void DeleteItem(RoomInfo i)
 {
     repo.DeleteItem(i);
 }
Exemple #6
0
 public void CreateItem(RoomInfo i)
 {
     repo.CreateItem(i);
 }
 public void UpdateItem(RoomInfo i)
 {
     repo.UpdateItem(i);
 }
 public void DeleteItem(RoomInfo i)
 {
     repo.DeleteItem(i);
 }
 public void CreateItem(RoomInfo i)
 {
     repo.CreateItem(i);
 }