示例#1
0
        public IActionResult AddRentalRoom(RoomRentalDto model)
        {
            var roomRental = model.MapTo <Room_rental>(mapper);

            //roomRental.Room = null;
            //roomRental.Organization = null;

            if (ModelState.IsValid)
            {
                unitOfWork.GetRepository <Room_rental>().InsertAsync(roomRental);
                unitOfWork.GetRepository <Room_rental>().Save();
                return(new ObjectResult("Model added successfully!"));
            }
            return(new ObjectResult("Model added unsuccessfully!"));
        }
示例#2
0
        public IActionResult UpdateRentalRoom(Guid id, RoomRentalDto model)
        {
            var room          = model.MapTo <Room_rental>(mapper);
            var newRoomRental = unitOfWork.GetRepository <Room_rental>().GetById(id);

            newRoomRental.InputDate  = room.InputDate;
            newRoomRental.OutputDate = room.OutputDate;

            if (ModelState.IsValid && id == model.Id)
            {
                unitOfWork.GetRepository <Room_rental>().Update(newRoomRental);
                unitOfWork.GetRepository <Room_rental>().Save();
                return(new ObjectResult("Model updated successfully!"));
            }
            return(new ObjectResult("Model updated unsuccessfully!"));
        }