public ActionResult CreateFloor(ViewModelFloor Model) { var userDetail = SessionHelper.GetUserDetailFromSession(); if (userDetail == null) { return(RedirectToAction("Index", "Login", new { ReturnUrl = "/Floor" })); } var UserId = Convert.ToInt32(userDetail.user.id); Guid g = Guid.NewGuid(); if (ModelState.IsValid) { Floor fl = new Floor(); fl.FloorName = Model.FloorName; fl.FloorNumber = Model.FloorNumber; fl.Description = Model.Description; fl.CreatedBy = UserId; fl.UpdatedBy = UserId; fl.FloorId = g; fl.IsActive = true; fl.Status = 1; fl.CreatedDate = DateTime.Now; fl.UpdatedDate = DateTime.Now; dc.Floors.Add(fl); dc.SaveChanges(); MRMLog _MRMLog = new MRMLog(); _MRMLog.UserId = Convert.ToInt32(UserId); _MRMLog.Action = "Create"; _MRMLog.Module = "Floor Create Operation"; _MRMLog.Description = userDetail.user.first_name + "_" + userDetail.user.last_name + " has Create Floor having id= " + g; _MRMLog.CreatedBy = Convert.ToInt32(UserId); _MRMLog.CraetedDate = DateTime.Now; dc.MRMLogs.Add(_MRMLog); dc.SaveChanges(); TempData["create"] = "donecrate"; return(RedirectToAction("Index", "Floor")); } return(View("FloorForm", Model)); }
public bool ActivateFloorReferenceID(Guid Id) { var userDetail = SessionHelper.GetUserDetailFromSession(); if (userDetail == null) { return(false); } else { var UserId = Convert.ToInt32(userDetail.user.id); RoomMeetingManagementDbEntities _db = new RoomMeetingManagementDbEntities(); // var Roomdata = _db.Rooms.Where(x => x.RoomId == Id && x.IsActive == true && x.Status == 0).ToList(); // var BookRoomdata = _db.BookRooms.Where(x => x.RoomId == Id && x.IsActive == true).ToList(); var floordata = _db.Floors.Where(x => x.FloorId == Id && x.IsActive == true && x.Status == 0).FirstOrDefault(); if (floordata != null) { floordata.Status = 1; floordata.UpdatedBy = UserId; floordata.UpdatedDate = DateTime.Now; _db.SaveChanges(); MRMLog _MRMLog = new MRMLog(); _MRMLog.UserId = Convert.ToInt32(UserId); _MRMLog.Action = "Active"; _MRMLog.Module = "Floor Active Operation"; _MRMLog.Description = userDetail.user.first_name + "_" + userDetail.user.last_name + " has Active Floor having id= " + floordata.FloorId; _MRMLog.CreatedBy = Convert.ToInt32(UserId); _MRMLog.CraetedDate = DateTime.Now; _db.MRMLogs.Add(_MRMLog); _db.SaveChanges(); return(true); } else { return(false); } } }
public bool DeleteRoomInfo(Guid Id) { RoomMeetingManagementDbEntities _db = new RoomMeetingManagementDbEntities(); var data = _db.Rooms.Where(x => x.RoomId == Id).FirstOrDefault(); if (data != null) { data.IsActive = false; data.UpdatedDate = DateTime.Now; _db.SaveChanges(); var userDetail = SessionHelper.GetUserDetailFromSession(); if (userDetail == null) { return(false); } else { var UserId = Convert.ToInt32(userDetail.user.id); MRMLog _MRMLog = new MRMLog(); _MRMLog.UserId = Convert.ToInt32(UserId); _MRMLog.Action = "Delete"; _MRMLog.Module = "Floor Delete Operation"; _MRMLog.Description = userDetail.user.first_name + "_" + userDetail.user.last_name + " has deleted Room having id= " + data.RoomId; _MRMLog.CreatedBy = Convert.ToInt32(UserId); _MRMLog.CraetedDate = DateTime.Now; _db.MRMLogs.Add(_MRMLog); _db.SaveChanges(); return(true); } } else { return(false); } }
public ActionResult ExportSolution() { var userDetail = SessionHelper.GetUserDetailFromSession(); if (userDetail == null) { return(RedirectToAction("Index", "Login", new { ReturnUrl = "/BookRoom" })); } int UserId = Convert.ToInt32(userDetail.user.id); var calendarevents = db.BookRooms.Where(x => x.UserId == UserId && x.IsSyncIcal == false && x.IsActive == true).ToList(); // var calendarevents = CM.calendardetailtomodel(); var FileTime = DateTime.Now.ToFileTime(); var ext = ".ics"; DDay.iCal.iCalendar iCal = new DDay.iCal.iCalendar(); foreach (var demoEvent in calendarevents) { Event evt = iCal.Create <Event>(); evt.Start = new iCalDateTime(demoEvent.StartDate); evt.End = new iCalDateTime(demoEvent.EndDate); evt.Description = demoEvent.Description; evt.Summary = demoEvent.Description; var datas = db.BookRooms.Where(x => x.BookRoomId == demoEvent.BookRoomId).FirstOrDefault(); if (datas != null) { datas.IsSyncIcal = true; db.SaveChanges();//update //TempData["StatusMsg"] = "Success"; } } ISerializationContext ctx = new SerializationContext(); ISerializerFactory factory = new DDay.iCal.Serialization.iCalendar.SerializerFactory(); // Get a serializer for our object IStringSerializer serializer = factory.Build(iCal.GetType(), ctx) as IStringSerializer; string output = serializer.SerializeToString(iCal); var contentType = "text/calendar"; var bytes = Encoding.UTF8.GetBytes(output); return(File(bytes, contentType, FileTime + ext)); }
public ActionResult CreateRoom(ViewModelRoom Model) { try { if (Model.MinCapacity > Model.MaxCapacity) { ViewBag.RoomtypeListVB = dc.RoomTypes.Where(x => x.IsActive == true && x.Status == 1).ToList(); ViewBag.FloorListVB = dc.Floors.Where(x => x.IsActive == true && x.Status == 1).ToList(); ViewBag.MinMax = "MinMax"; return(View("Create", Model)); } var userDetail = SessionHelper.GetUserDetailFromSession(); if (userDetail == null) { return(RedirectToAction("Index", "Login", new { ReturnUrl = "/Rooms" })); } ObjectParameter returnId = new ObjectParameter("Exists", typeof(int)); var exist = dc.IsExistRooms(Model.RoomName, Model.RoomNumber, returnId).ToList(); int Roomexist = Convert.ToInt32(returnId.Value); if (Roomexist == 0) { var UserId = Convert.ToInt32(userDetail.user.id); Guid g = Guid.NewGuid(); if (ModelState.IsValid) { List <ViewModelRoomPictureMapping> fileDetails = new List <ViewModelRoomPictureMapping>(); for (int i = 0; i < Request.Files.Count; i++) { var file = Request.Files[i]; if (file != null && file.ContentLength > 0) { RoomPictureMapping rpc = new RoomPictureMapping(); var ActualfileName = Path.GetFileName(file.FileName); var FileTime = DateTime.Now.ToFileTime(); string fileName = Path.GetFileNameWithoutExtension(file.FileName) + "_" + FileTime + Path.GetExtension(file.FileName); rpc.FileName = fileName; rpc.ActualFileName = ActualfileName; rpc.Extension = Path.GetExtension(fileName); rpc.RoomPictureMappingId = Guid.NewGuid(); rpc.RoomId = g; rpc.CreatedDate = DateTime.Now; rpc.UpdatedDate = DateTime.Now; rpc.CreatedBy = UserId; rpc.UpdatedBy = UserId; dc.RoomPictureMappings.Add(rpc); dc.SaveChanges(); var path = Path.Combine(Server.MapPath("~/Rotativa/RoomImage/"), Path.GetFileNameWithoutExtension(file.FileName) + "_" + FileTime + Path.GetExtension(file.FileName)); file.SaveAs(path); } } Room rm = new Room(); rm.RoomId = g; rm.IsActive = true; rm.Status = 1; rm.CreatedDate = DateTime.Now; rm.UpdatedDate = DateTime.Now; rm.FloorId = Model.FloorId; rm.RoomTypeId = Model.RoomTypeId; rm.Capacity = Model.Capacity; rm.MinCapacity = Model.MinCapacity; rm.MaxCapacity = Model.MaxCapacity; rm.RoomNumber = Model.RoomNumber; rm.RoomName = Model.RoomName; rm.Description = Model.Description; rm.CreatedBy = UserId; rm.UpdatedBy = UserId; dc.Rooms.Add(rm); dc.SaveChanges(); MRMLog _MRMLog = new MRMLog(); _MRMLog.UserId = Convert.ToInt32(UserId); _MRMLog.Action = "Create"; _MRMLog.Module = "Room Create Operation"; _MRMLog.Description = userDetail.user.first_name + "_" + userDetail.user.last_name + " has Create Room having id= " + g; _MRMLog.CreatedBy = Convert.ToInt32(UserId); _MRMLog.CraetedDate = DateTime.Now; dc.MRMLogs.Add(_MRMLog); dc.SaveChanges(); TempData["create"] = "donecrate"; return(RedirectToAction("Index", "Rooms")); } return(View("Create", Model)); } else { ViewBag.RoomtypeListVB = dc.RoomTypes.Where(x => x.IsActive == true && x.Status == 1).ToList(); ViewBag.FloorListVB = dc.Floors.Where(x => x.IsActive == true && x.Status == 1).ToList(); Model.IsExist = true; ViewBag.IsExistRoom = 1; return(View("Create", Model)); } } catch (Exception ex) { return(RedirectToAction("Index", "Login", new { ReturnUrl = "/Rooms" })); } }
public int SaveRoomInfo(ViewModelRoom Model) { RoomMeetingManagementDbEntities _db = new RoomMeetingManagementDbEntities(); var userDetail = SessionHelper.GetUserDetailFromSession(); if (userDetail == null) { return(3); } var UserId = Convert.ToInt32(userDetail.user.id); if (userDetail != null) { if (1 == 1) { var data = _db.Rooms.Where(x => x.RoomName == Model.RoomName || x.RoomId == Model.RoomId).FirstOrDefault(); if (data == null) { return(0); } else { var datas = _db.Rooms.Where(x => x.RoomId == Model.RoomId).FirstOrDefault(); if (datas != null) { datas.RoomName = Model.RoomName; datas.Description = Model.Description; datas.Status = Model.Status; datas.Capacity = Model.Capacity; datas.MinCapacity = (int)Model.MinCapacity; datas.MaxCapacity = (int)Model.MaxCapacity; datas.CreatedBy = Model.CreatedBy; datas.UpdatedBy = Convert.ToInt32(UserId); datas.UpdatedDate = DateTime.Now; _db.SaveChanges();//update MRMLog _MRMLog = new MRMLog(); _MRMLog.UserId = Convert.ToInt32(UserId); _MRMLog.Action = "Update"; _MRMLog.Module = "Room Update Operation"; _MRMLog.Description = userDetail.user.first_name + "_" + userDetail.user.last_name + " has Updated Room having id= " + datas.RoomId; _MRMLog.CreatedBy = Convert.ToInt32(UserId); _MRMLog.CraetedDate = DateTime.Now; _db.MRMLogs.Add(_MRMLog); _db.SaveChanges(); } return(1); } } else { var data = _db.Rooms.Where(x => x.RoomName == Model.RoomName && x.IsActive == true).FirstOrDefault(); if (data != null) { return(0); } else { Room _Roomdata = new Room(); Guid g = Guid.NewGuid(); _Roomdata.RoomId = g; _Roomdata.RoomName = Model.RoomName; _Roomdata.Description = Model.Description; _Roomdata.Status = Model.Status; _Roomdata.IsActive = true; _Roomdata.Capacity = Model.Capacity; _Roomdata.MinCapacity = (int)Model.MinCapacity; _Roomdata.MaxCapacity = (int)Model.MaxCapacity; _Roomdata.CreatedBy = Convert.ToInt32(UserId); _Roomdata.UpdatedBy = Convert.ToInt32(UserId); _Roomdata.CreatedDate = DateTime.Now; _Roomdata.UpdatedDate = DateTime.Now; _db.Rooms.Add(_Roomdata); _db.SaveChanges(); return(1); } } } else { return(2); } }
public bool DeActivateRoomReferenceID(Guid Id) { var userDetail = SessionHelper.GetUserDetailFromSession(); if (userDetail == null) { return(false); } else { var UserId = Convert.ToInt32(userDetail.user.id); RoomMeetingManagementDbEntities _db = new RoomMeetingManagementDbEntities(); var Roomdata = _db.Rooms.Where(x => x.RoomId == Id && x.IsActive == true).ToList(); var BookRoomdata = _db.BookRooms.Where(x => x.RoomId == Id && x.IsActive == true).ToList(); if (Roomdata != null) { foreach (var item in Roomdata) { if (item.Status == 1) { item.Status = 0; item.UpdatedBy = UserId; item.UpdatedDate = DateTime.Now; _db.SaveChanges(); MRMLog _MRMLog = new MRMLog(); _MRMLog.UserId = Convert.ToInt32(UserId); _MRMLog.Action = "DeActive"; _MRMLog.Module = "Room DeActive Operation"; _MRMLog.Description = userDetail.user.first_name + "_" + userDetail.user.last_name + " has DeActive Room having id= " + item.RoomId; _MRMLog.CreatedBy = Convert.ToInt32(UserId); _MRMLog.CraetedDate = DateTime.Now; _db.MRMLogs.Add(_MRMLog); _db.SaveChanges(); } else { item.Status = 1; item.UpdatedBy = UserId; item.UpdatedDate = DateTime.Now; _db.SaveChanges(); MRMLog _MRMLog = new MRMLog(); _MRMLog.UserId = Convert.ToInt32(UserId); _MRMLog.Action = "Active"; _MRMLog.Module = "Room Active Operation"; _MRMLog.Description = userDetail.user.first_name + "_" + userDetail.user.last_name + " has Active Room having id= " + item.RoomId; _MRMLog.CreatedBy = Convert.ToInt32(UserId); _MRMLog.CraetedDate = DateTime.Now; _db.MRMLogs.Add(_MRMLog); _db.SaveChanges(); } //item.UpdatedBy = UserId; //item.UpdatedDate = DateTime.Now; //_db.SaveChanges(); } } if (BookRoomdata != null) { foreach (var item in BookRoomdata) { item.IsActive = false; item.UpdatedBy = UserId; item.UpdatedDate = DateTime.Now; _db.SaveChanges(); MRMLog _MRMLog = new MRMLog(); _MRMLog.UserId = Convert.ToInt32(UserId); _MRMLog.Action = "DeActive"; _MRMLog.Module = "Room DeActive Operation"; _MRMLog.Description = userDetail.user.first_name + "_" + userDetail.user.last_name + " has DeActive BookRoom having id= " + item.BookRoomId; _MRMLog.CreatedBy = Convert.ToInt32(UserId); _MRMLog.CraetedDate = DateTime.Now; _db.MRMLogs.Add(_MRMLog); _db.SaveChanges(); } return(true); } else { return(false); } } }
public int SaveFloorInfo(ViewModelFloor Model) { RoomMeetingManagementDbEntities _db = new RoomMeetingManagementDbEntities(); var userDetail = SessionHelper.GetUserDetailFromSession(); if (userDetail != null) { var UserId = Convert.ToInt32(userDetail.user.id); if (1 == 1) { var data = _db.Floors.Where(x => x.FloorName == Model.FloorName || x.FloorId == Model.FloorId).FirstOrDefault(); if (data == null) { return(0); } else { var datas = _db.Floors.Where(x => x.FloorId == Model.FloorId).FirstOrDefault(); if (datas != null) { datas.FloorName = Model.FloorName; datas.FloorNumber = Model.FloorNumber; datas.Description = Model.Description; datas.Status = Model.Status; datas.CreatedBy = Model.CreatedBy; datas.UpdatedBy = Convert.ToInt32(UserId); datas.UpdatedDate = DateTime.Now; _db.SaveChanges();//update MRMLog _MRMLog = new MRMLog(); _MRMLog.UserId = Convert.ToInt32(UserId); _MRMLog.Action = "Update"; _MRMLog.Module = "Floor Update Operation"; _MRMLog.Description = userDetail.user.first_name + "_" + userDetail.user.last_name + " has Updated Floor having id= " + datas.FloorId; _MRMLog.CreatedBy = Convert.ToInt32(UserId); _MRMLog.CraetedDate = DateTime.Now; _db.MRMLogs.Add(_MRMLog); _db.SaveChanges(); } return(1); } } else { var data = _db.Floors.Where(x => x.FloorName == Model.FloorName && x.IsActive == true).FirstOrDefault(); if (data != null) { return(0); } else { Floor _floordata = new Floor(); Guid g = Guid.NewGuid(); _floordata.FloorId = g; _floordata.FloorName = Model.FloorName; _floordata.FloorNumber = Model.FloorNumber; _floordata.Description = Model.Description; _floordata.Status = Model.Status; _floordata.IsActive = true; _floordata.CreatedBy = Convert.ToInt32(UserId); _floordata.UpdatedBy = Convert.ToInt32(UserId); _floordata.CreatedDate = DateTime.Now; _floordata.UpdatedDate = DateTime.Now; _db.Floors.Add(_floordata); _db.SaveChanges(); return(1); } } } else { return(2); } }
public int SaveCalEventInfo(ViewModelCalendarRoomDetail Model) { var userDetail = SessionHelper.GetUserDetailFromSession(); if (userDetail == null) { return(3); } var UserId = Convert.ToInt32(userDetail.user.id); var Roomdetails = getRoom_ListValueById((Guid)Model.RoomId); try { //ObjectParameter returnId = new ObjectParameter("Exists", typeof(int)); ObjectParameter returnId = new ObjectParameter("Exists", typeof(int)); //var exist= _Db.CheckRoomExist(Model.Start, Model.End, Model.RoomId); CultureInfo culture = new CultureInfo("en-US"); DateTime StartDate = DateTime.ParseExact(Model.Start, "dd/MM/yyyy", culture); DateTime EndDate = DateTime.ParseExact(Model.End, "dd/MM/yyyy", culture); DateTime Start = new DateTime(StartDate.Year, StartDate.Month, StartDate.Day, Model.sHour, Model.sMin, StartDate.Second, 0); DateTime End = new DateTime(EndDate.Year, EndDate.Month, EndDate.Day, Model.eHour, Model.eMin, EndDate.Second, 0); if (Start > End) { return(5); } var exist = _Db.CheckRoomExist1(Start, End, Model.RoomId, returnId).ToList(); int recordexist = Convert.ToInt32(returnId.Value); if (recordexist == 0) { BookRoom bm = new BookRoom(); Guid RoomId = Guid.NewGuid(); bm.RoomId = Model.RoomId; Guid BookRoomId = Guid.NewGuid(); bm.BookRoomId = BookRoomId; bm.UserId = UserId; bm.DId = 1; bm.StartDate = Start; bm.EndDate = End; bm.Description = Model.Description; //bm.FloorId = Roomdetails.FloorId; //bm.RoomTypeId = Roomdetails.RoomTypeId; bm.Capacity = Model.Capacity; bm.CreatedDate = DateTime.Now; bm.UpdatedDate = DateTime.Now; bm.CreatedBy = UserId; bm.UpdatedBy = UserId; if (Roomdetails != null) { bm.FloorId = Roomdetails.FloorId; bm.RoomTypeId = Roomdetails.RoomTypeId; } bm.IsActive = true; bm.IsSyncOutlookCal = false; bm.IsSyncGoogleCal = false; bm.IsSyncIcal = false; _Db.BookRooms.Add(bm); _Db.SaveChanges(); return(1); } else if (recordexist == 1) { return(2); } else { return(4); } } catch (Exception ex) { return(0); } }