public ActionResult AddRoomType(RoomType roomType, string action = "", int id = 0) { if (id == 0 && action == "Add") { ServiceRoom.AddRoomType(roomType, id); return(View()); } else if (id != 0 && action == "Save") { RoomType temp = db.RoomTypes.FirstOrDefault(f => f.RoomTypeId == id); roomType.RoomTypeId = id; db.Entry(temp).CurrentValues.SetValues(roomType); db.SaveChanges(); return(View(roomType)); } else if (id != 0) { return(View(db.RoomTypes.FirstOrDefault(f => f.RoomTypeId == id))); } else { return(View()); } }
public ActionResult AddRoom(Room room, string action, int statusCode = -1, int roomId = 0) { ViewBag.RoomTypeList = db.RoomTypes.Select(s => new SelectListItem() { Text = s.Name, Value = s.RoomTypeId.ToString() }).ToList(); if (room.RoomId == 0 && action == "Add") { if (ServiceRoom.AddRoom(room)) { return(RedirectToAction("Index")); } } if (action == "Save") { if (ServiceRoom.SaveRoom(room)) { return(RedirectToAction("Index")); } } else if (room.RoomId != 0 && roomId != 0) { room = db.Rooms.Find(roomId); return(View(room)); } ViewBag.StatusCode = 1; return(View()); }
public async Task <Result <LinkageServiceRoomResponse> > Handle(LinkageServiceRoomCommand request, CancellationToken cancellationToken) { using (_queueUnitOfWork) { try { if (request.Linkagelist != null) { if (request.Linkagelist.Count > 0) { foreach (var link in request.Linkagelist) { var srvroom = await _queueUnitOfWork.Repository <ServiceRoom>().Get(x => x.ServiceAreaid == link.ServiceAreaId && x.ServicePointId == link.ServicePointId && x.RoomId == link.Roomid).FirstOrDefaultAsync(); if (srvroom != null) { srvroom.RoomId = link.Roomid; srvroom.ServiceAreaid = link.ServiceAreaId; srvroom.ServicePointId = link.ServicePointId; srvroom.DeleteFlag = false; srvroom.UpdateDate = DateTime.Now; srvroom.UpdatedBy = link.UserId; _queueUnitOfWork.Repository <ServiceRoom>().Update(srvroom); await _queueUnitOfWork.SaveAsync(); } else { ServiceRoom rm = new ServiceRoom(); rm.RoomId = link.Roomid; rm.ServiceAreaid = link.ServiceAreaId; rm.ServicePointId = link.ServicePointId; rm.Active = true; rm.CreateDate = DateTime.Now; rm.CreatedBy = link.UserId; await _queueUnitOfWork.Repository <ServiceRoom>().AddAsync(rm); await _queueUnitOfWork.SaveAsync(); } } } } return(Result <LinkageServiceRoomResponse> .Valid(new LinkageServiceRoomResponse() { Message = "The linkage was added successfully" })); } catch (Exception ex) { Log.Error(ex.Message); return(Result <LinkageServiceRoomResponse> .Invalid(ex.Message)); } } }
public ActionResult RoomTypeDelete(int id) { ServiceRoom.RoomTypeDelete(id); return(RedirectToAction("RoomTypeIndex")); }
public ActionResult Delete(int roomId) { ServiceRoom.DeleteRoom(roomId); return(RedirectToAction("Index")); }