Ejemplo n.º 1
0
 public ActionResult Create(ViewModelRoom Model)
 {
     try
     {
         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();
         ModelState.Clear();
         return(View(Model));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("Index", "Login", new { ReturnUrl = "/Rooms" }));
     }
 }
Ejemplo n.º 2
0
        public ViewModelRoom GetRoomDetailsById(Guid Id)
        {
            ViewModelRoom model = new ViewModelRoom();
            RoomMeetingManagementDbEntities    _db         = new RoomMeetingManagementDbEntities();
            List <ViewModelRoomPictureMapping> ListPicture = new List <ViewModelRoomPictureMapping>();

            var picturedata = _db.RoomPictureMappings.Where(x => x.RoomId == Id).ToList();
            var data        = _db.Rooms.Where(x => x.RoomId == Id && x.IsActive == true).FirstOrDefault();

            if (data != null)
            {
                model.DId         = data.DId;
                model.RoomId      = data.RoomId;
                model.FloorId     = data.FloorId;
                model.RoomTypeId  = data.RoomTypeId;
                model.RoomName    = data.RoomName;
                model.RoomNumber  = (int)data.RoomNumber;
                model.Description = data.Description;
                model.Capacity    = data.Capacity;
                if (data.MinCapacity != null)
                {
                    model.MinCapacity = (int)data.MinCapacity;
                }
                if (data.MaxCapacity != null)
                {
                    model.MaxCapacity = (int)data.MaxCapacity;
                }
                model.Status = (int)data.Status;
                if (picturedata.Count > 0)
                {
                    var comCount = 0;
                    foreach (var item in picturedata)
                    {
                        ViewModelRoomPictureMapping cm = new ViewModelRoomPictureMapping();
                        comCount++;
                        cm.RoomPictureMappingId = item.RoomPictureMappingId;
                        cm.ActualFileName       = item.ActualFileName;
                        cm.DId       = item.DId;
                        cm.count     = comCount;
                        cm.RoomId    = item.RoomId;
                        cm.FileName  = item.FileName;
                        cm.Extension = item.Extension;
                        ListPicture.Add(cm);
                    }
                }
                model.RoomPictureMappingsList = ListPicture;
            }
            return(model);
        }
Ejemplo n.º 3
0
        public List <ViewModelRoom> GetAllRoomList()
        {
            List <ViewModelRoom>            Model = new List <ViewModelRoom>();
            RoomMeetingManagementDbEntities dc    = new RoomMeetingManagementDbEntities();
            var data = dc.Rooms.Where(x => x.IsActive == true).OrderByDescending(x => x.DId).ToList();

            if (data.Count > 0)
            {
                var count = 0;
                foreach (var item in data)
                {
                    ViewModelRoom model = new ViewModelRoom();
                    count++;
                    model.Count      = count;
                    model.DId        = item.DId;
                    model.RoomId     = item.RoomId;
                    model.FloorId    = item.RoomId;
                    model.RoomTypeId = item.RoomTypeId;
                    model.RoomName   = item.RoomName;
                    model.Capacity   = item.Capacity;
                    var floordetails    = getfloor_ListValueById((Guid)item.FloorId);
                    var Roomtypedetails = getRoomtype_ListValueById((Guid)item.RoomTypeId);
                    if (item.MinCapacity != null)
                    {
                        model.MinCapacity = (int)item.MinCapacity;
                    }
                    if (item.MaxCapacity != null)
                    {
                        model.MaxCapacity = (int)item.MaxCapacity;
                    }
                    if (floordetails != null)
                    {
                        model.Floor = floordetails.FloorName;
                    }
                    if (Roomtypedetails != null)
                    {
                        model.Roomtype = Roomtypedetails.RoomtypeName;
                    }
                    model.Status      = (int)item.Status;
                    model.Description = item.Description;
                    model.CreatedBy   = (int)item.CreatedBy;
                    model.UpdatedBy   = (int)item.UpdatedBy;
                    model.CreatedDate = (DateTime)item.CreatedDate;
                    model.UpdatedDate = (DateTime)item.UpdatedDate;
                    Model.Add(model);
                }
            }
            return(Model);
        }
Ejemplo n.º 4
0
 public ActionResult Edit(Guid id)
 {
     try
     {
         if (id == null)
         {
             return(null);
         }
         ViewModelRoom Room = _RoomMethods.GetRoomDetailsById(id);
         // ViewModelRoom Room = dc.Rooms.Include(s => s.RoomPictureMappings).SingleOrDefault(x => x.RoomId == id);
         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();
         if (Room == null)
         {
             return(HttpNotFound());
         }
         return(View("RoomForm", Room));
     }
     catch {
         return(RedirectToAction("Index", "Login", new { ReturnUrl = "/Rooms" }));
     }
 }
Ejemplo n.º 5
0
        public ActionResult Edit(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("RoomForm", Model));
                }

                var userDetail = SessionHelper.GetUserDetailFromSession();
                if (userDetail == null)
                {
                    return(RedirectToAction("Index", "Login", new { ReturnUrl = "/Rooms" }));
                }

                var UserId = Convert.ToInt32(userDetail.user.id);
                if (ModelState.IsValid)
                {
                    //New Files
                    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      = Model.RoomId;
                            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);
                        }
                    }
                    var data = dc.Rooms.Where(x => x.RoomId == Model.RoomId).FirstOrDefault();
                    if (data != null)
                    {
                        data.FloorId       = Model.FloorId;
                        data.RoomTypeId    = Model.RoomTypeId;
                        data.RoomName      = Model.RoomName;
                        data.RoomNumber    = (int)Model.RoomNumber;
                        data.Description   = Model.Description;
                        data.Capacity      = Model.Capacity;
                        data.MinCapacity   = Model.MinCapacity;
                        data.MaxCapacity   = Model.MaxCapacity;
                        data.UpdatedBy     = UserId;
                        data.UpdatedDate   = DateTime.Now;
                        Model.Status       = 1;
                        Model.IsActive     = true;
                        TempData["update"] = "doneupdate";
                        dc.SaveChanges();

                        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= " + Model.RoomId;
                        _MRMLog.CreatedBy   = Convert.ToInt32(UserId);
                        _MRMLog.CraetedDate = DateTime.Now;
                        dc.MRMLogs.Add(_MRMLog);
                        dc.SaveChanges();
                    }
                    return(RedirectToAction("Index", "Rooms"));
                }
                return(View("Roomform", Model));
            }
            catch (Exception ex) {
                string filePath = Server.MapPath("~/Rotativa/Bug/Error.txt");
                using (StreamWriter writer = new StreamWriter(filePath, true))
                {
                    writer.WriteLine("-----------------------------------------------------------------------------");
                    writer.WriteLine("Date : " + DateTime.Now.ToString());
                    writer.WriteLine();

                    while (ex != null)
                    {
                        writer.WriteLine(ex.GetType().FullName);
                        writer.WriteLine("Message : " + ex.Message);
                        writer.WriteLine("StackTrace : " + ex.StackTrace);
                        writer.WriteLine("InnerException : " + ex.InnerException);
                        ex = ex.InnerException;
                    }
                }
                return(RedirectToAction("Index", "Login", new { ReturnUrl = "/Rooms" }));
            };
        }
Ejemplo n.º 6
0
        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" })); }
        }
Ejemplo n.º 7
0
        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);
            }
        }