示例#1
0
        public ActionResult DeleteRoom(int roomId, int sequencenumber)
        {
            if (IsUserLoggedIn())
            {
                Models.MoveToLondon mtl        = new Models.MoveToLondon();
                List <Room>         rooms      = mtl.Rooms.Where(o => o.RoomSequence == sequencenumber).ToList();
                List <int>          roomids    = new List <int>();
                List <int>          photoids   = new List <int>();
                List <string>       photopaths = new List <string>();
                foreach (Room room in rooms)
                {
                    if (!roomids.Contains(room.ID))
                    {
                        roomids.Add(room.ID);
                    }
                    List <RoomsPhotosBridge> bridges = room.RoomsPhotosBridges.ToList();

                    foreach (RoomsPhotosBridge bridge in bridges)
                    {
                        if (!photoids.Contains(bridge.PhotoId))
                        {
                            photoids.Add(bridge.PhotoId);
                            photopaths.Add(bridge.RoomPhoto.Path);
                        }
                        mtl.Entry(bridge).State = System.Data.Entity.EntityState.Deleted;
                    }
                }

                mtl.SaveChanges();
                mtl = null;
                mtl = new Models.MoveToLondon();
                foreach (int id in roomids)
                {
                    Room r = new Room();
                    r.ID = id;
                    mtl.Entry(r).State = System.Data.Entity.EntityState.Deleted;
                }

                foreach (int id in photoids)
                {
                    RoomPhoto rf = new RoomPhoto();
                    rf.ID = id;
                    mtl.Entry(rf).State = System.Data.Entity.EntityState.Deleted;
                }
                //string serverpath = Server.MapPath(@"/");
                //foreach (string path in photopaths)
                //{

                //}
                mtl.SaveChanges();
                return(RedirectToAction("roomslist"));
            }
            else
            {
                return(RedirectToAction("index"));
            }
        }
示例#2
0
        public ActionResult DeleteRoom(int roomId, int sequencenumber)
        {
            if (IsUserLoggedIn())
            {
                Models.MoveToLondon mtl = new Models.MoveToLondon();
                List<Room> rooms = mtl.Rooms.Where(o => o.RoomSequence == sequencenumber).ToList();
                List<int> roomids = new List<int>();
                List<int> photoids = new List<int>();
                List<string> photopaths = new List<string>();
                foreach (Room room in rooms)
                {
                    if (!roomids.Contains(room.ID))
                        roomids.Add(room.ID);
                    List<RoomsPhotosBridge> bridges = room.RoomsPhotosBridges.ToList();

                    foreach (RoomsPhotosBridge bridge in bridges)
                    {
                        if (!photoids.Contains(bridge.PhotoId))
                        {
                            photoids.Add(bridge.PhotoId);
                            photopaths.Add(bridge.RoomPhoto.Path);
                        }
                        mtl.Entry(bridge).State = System.Data.Entity.EntityState.Deleted;
                    }
                }

                mtl.SaveChanges();
                mtl = null;
                mtl = new Models.MoveToLondon();
                foreach (int id in roomids)
                {
                    Room r = new Room();
                    r.ID = id;
                    mtl.Entry(r).State = System.Data.Entity.EntityState.Deleted;
                }

                foreach (int id in photoids)
                {
                    RoomPhoto rf = new RoomPhoto();
                    rf.ID = id;
                    mtl.Entry(rf).State = System.Data.Entity.EntityState.Deleted;
                }
                //string serverpath = Server.MapPath(@"/");
                //foreach (string path in photopaths)
                //{

                //}
                mtl.SaveChanges();
                return RedirectToAction("roomslist");
            }
            else
            {
                return RedirectToAction("index");
            }
        }
示例#3
0
 public ActionResult roomslist()
 {
     if (IsUserLoggedIn())
     {
         RoomData            rd  = new RoomData();
         Models.MoveToLondon mtl = new Models.MoveToLondon();
         rd.Rooms = mtl.Rooms.Where(o => !o.IsFrench).ToList();
         return(View(rd));
     }
     else
     {
         return(RedirectToAction("index"));
     }
 }
示例#4
0
        public ActionResult Login(UserData input)
        {
            Models.MoveToLondon mtl = new Models.MoveToLondon();
            UserProfile         uf  = mtl.UserProfiles.FirstOrDefault();
            UserData            ud  = Session["UserData"] as UserData;
            string pass             = uf.Password;

            if (input.UserName == uf.UserName && input.Password == pass)
            {
                ud.IsLoggedIn = true;
                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("Login"));
            }
        }
示例#5
0
        public ActionResult SaveAd()
        {
            if (IsUserLoggedIn())
            {
                try
                {
                    RoomData rd = Session["RoomsData"] as RoomData;
                    if (rd == null)
                    {
                        return RedirectToAction("index", "admin");
                    }

                    Models.MoveToLondon mtl = new Models.MoveToLondon();

                    for (int i = 0; i < rd.Rooms.Count; i++)
                    {
                        for (int j = 0; j < rd.RoomPhotos.Count; j++)
                        {
                            RoomsPhotosBridge rpb = new RoomsPhotosBridge();
                            rpb.Room = rd.Rooms[i];
                            rpb.RoomPhoto = rd.RoomPhotos[j];

                            mtl.Set<RoomsPhotosBridge>().Add(rpb);

                            //rd.Rooms[i].RoomsPhotosBridges.Clear();
                            //rd.RoomPhotos[j].RoomsPhotosBridges.Clear();

                            rd.Rooms[i].RoomsPhotosBridges.Add(rpb);
                            rd.RoomPhotos[j].RoomsPhotosBridges.Add(rpb);
                        }
                    }
                    Room r = mtl.Rooms.ToList().Last();
                    if (r != null)
                    {
                        rd.Rooms[0].RoomSequence = r.ID + 1;
                        rd.Rooms[1].RoomSequence = r.ID + 1;
                    }
                    else
                    {
                        rd.Rooms[0].RoomSequence = 0;
                        rd.Rooms[1].RoomSequence = 0;
                    }

                    foreach (Room room in rd.Rooms)
                    {
                        mtl.Set<Room>().Add(room);
                    }
                    foreach (RoomPhoto photo in rd.RoomPhotos)
                    {
                        mtl.Set<RoomPhoto>().Add(photo);
                    }
                    mtl.SaveChanges();
                }
                catch (Exception ex)
                {

                    throw;
                }

                return RedirectToAction("roomslist");
            }
            else
            {
                return RedirectToAction("index");
            }
        }
示例#6
0
 public ActionResult roomslist()
 {
     if (IsUserLoggedIn())
     {
         RoomData rd = new RoomData();
         Models.MoveToLondon mtl = new Models.MoveToLondon();
         rd.Rooms = mtl.Rooms.Where(o => !o.IsFrench).ToList();
         return View(rd);
     }
     else
     {
         return RedirectToAction("index");
     }
 }
示例#7
0
 public ActionResult Login(UserData input)
 {
     Models.MoveToLondon mtl = new Models.MoveToLondon();
     UserProfile uf = mtl.UserProfiles.FirstOrDefault();
     UserData ud = Session["UserData"] as UserData;
     string pass = uf.Password;
     if (input.UserName == uf.UserName && input.Password == pass)
     {
         ud.IsLoggedIn = true;
         return RedirectToAction("Index");
     }
     else
     {
         return RedirectToAction("Login");
     }
 }
示例#8
0
        private List <Room> GetListOfRooms()
        {
            Models.MoveToLondon mtl = new Models.MoveToLondon();

            List <Room> rooms = new List <Models.Room>();

            if (Convert.ToBoolean(Session["IsEnglishVersion"]) == true)
            {
                rooms = mtl.Rooms.Where(o => !o.IsFrench).ToList();
            }
            else
            {
                rooms = mtl.Rooms.Where(o => o.IsFrench).ToList();
            }

            return(rooms);

            string serverMapPath = Server.MapPath(@"/");
            string filepath      = Convert.ToBoolean(Session["IsEnglishVersion"]) ? serverMapPath + ConfigurationManager.AppSettings["EnglishRoomDataFilePath"].ToString()
                : serverMapPath + ConfigurationManager.AppSettings["FrenchRoomDataFilePath"].ToString();
            string      line                 = string.Empty;
            List <Room> roomsList            = new List <Room>();
            int         roomsCounter         = -1;
            bool        isDescriptionStarted = false;
            string      description          = string.Empty;
            bool        isPathsStarted       = false;

            using (StreamReader sr = new StreamReader(filepath))
            {
                while ((line = sr.ReadLine()) != null)
                {
                    if (string.IsNullOrWhiteSpace(line))
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(line))
                    {
                        continue;
                    }

                    if (line.StartsWith("***"))
                    {
                        Room room = new Room();
                        roomsList.Add(room);
                        roomsCounter++;
                        isPathsStarted = false;
                        continue;
                    }
                    if (line.Trim().ToLower().StartsWith("title:"))
                    {
                        roomsList[roomsCounter].Title = line.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries)[1];
                        continue;
                    }
                    if (line.Trim().ToLower().StartsWith("address:"))
                    {
                        roomsList[roomsCounter].Address = line.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries)[1];
                        continue;
                    }
                    if (line.Trim().ToLower().StartsWith("rentpermonth:"))
                    {
                        int rent = 0;
                        int.TryParse(line.Trim().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries)[1], out rent);
                        roomsList[roomsCounter].RentPerMonth = rent;
                        continue;
                    }
                    if (line.Trim().ToLower().StartsWith("description:"))
                    {
                        isDescriptionStarted = true;
                        description         += line.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries)[1];
                        continue;
                    }
                    if (line.Trim().ToLower().StartsWith("photospaths:"))
                    {
                        isDescriptionStarted = false;
                        roomsList[roomsCounter].Description = description;
                        description    = string.Empty;
                        isPathsStarted = true;
                        continue;
                    }
                    if (isDescriptionStarted)
                    {
                        description += "\n" + line;
                    }
                    if (isPathsStarted)
                    {
                        RoomPhoto rf = new RoomPhoto();
                        rf.Path = line.Trim();
                        //if (roomsList[roomsCounter].ListRoomPhoto == null)
                        //    roomsList[roomsCounter].ListRoomPhoto = new List<RoomPhoto>();
                        //roomsList[roomsCounter].ListRoomPhoto.Add(rf);
                    }
                }
            }

            return(roomsList);
        }
示例#9
0
        private List<Room> GetListOfRooms()
        {
            Models.MoveToLondon mtl = new Models.MoveToLondon();

            List<Room> rooms = new List<Models.Room>();
            if (Convert.ToBoolean(Session["IsEnglishVersion"]) == true)
            {
                rooms = mtl.Rooms.Where(o => !o.IsFrench).ToList();
            }
            else
            {
                rooms = mtl.Rooms.Where(o => o.IsFrench).ToList();
            }

            return rooms;

            string serverMapPath = Server.MapPath(@"/");
            string filepath = Convert.ToBoolean(Session["IsEnglishVersion"]) ? serverMapPath + ConfigurationManager.AppSettings["EnglishRoomDataFilePath"].ToString()
                : serverMapPath + ConfigurationManager.AppSettings["FrenchRoomDataFilePath"].ToString();
            string line = string.Empty;
            List<Room> roomsList = new List<Room>();
            int roomsCounter = -1;
            bool isDescriptionStarted = false;
            string description = string.Empty;
            bool isPathsStarted = false;

            using (StreamReader sr = new StreamReader(filepath))
            {
                while ((line = sr.ReadLine()) != null)
                {
                    if (string.IsNullOrWhiteSpace(line))
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(line))
                    {
                        continue;
                    }

                    if (line.StartsWith("***"))
                    {
                        Room room = new Room();
                        roomsList.Add(room);
                        roomsCounter++;
                        isPathsStarted = false;
                        continue;
                    }
                    if (line.Trim().ToLower().StartsWith("title:"))
                    {
                        roomsList[roomsCounter].Title = line.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries)[1];
                        continue;
                    }
                    if (line.Trim().ToLower().StartsWith("address:"))
                    {
                        roomsList[roomsCounter].Address = line.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries)[1];
                        continue;
                    }
                    if (line.Trim().ToLower().StartsWith("rentpermonth:"))
                    {
                        int rent = 0;
                        int.TryParse(line.Trim().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries)[1], out rent);
                        roomsList[roomsCounter].RentPerMonth = rent;
                        continue;
                    }
                    if (line.Trim().ToLower().StartsWith("description:"))
                    {

                        isDescriptionStarted = true;
                        description += line.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries)[1];
                        continue;
                    }
                    if (line.Trim().ToLower().StartsWith("photospaths:"))
                    {
                        isDescriptionStarted = false;
                        roomsList[roomsCounter].Description = description;
                        description = string.Empty;
                        isPathsStarted = true;
                        continue;
                    }
                    if (isDescriptionStarted)
                    {

                        description += "\n" + line;
                    }
                    if (isPathsStarted)
                    {
                        RoomPhoto rf = new RoomPhoto();
                        rf.Path = line.Trim();
                        //if (roomsList[roomsCounter].ListRoomPhoto == null)
                        //    roomsList[roomsCounter].ListRoomPhoto = new List<RoomPhoto>();
                        //roomsList[roomsCounter].ListRoomPhoto.Add(rf);
                    }

                }
            }

            return roomsList;
        }
示例#10
0
        public ActionResult SaveAd()
        {
            if (IsUserLoggedIn())
            {
                try
                {
                    RoomData rd = Session["RoomsData"] as RoomData;
                    if (rd == null)
                    {
                        return(RedirectToAction("index", "admin"));
                    }

                    Models.MoveToLondon mtl = new Models.MoveToLondon();

                    for (int i = 0; i < rd.Rooms.Count; i++)
                    {
                        for (int j = 0; j < rd.RoomPhotos.Count; j++)
                        {
                            RoomsPhotosBridge rpb = new RoomsPhotosBridge();
                            rpb.Room      = rd.Rooms[i];
                            rpb.RoomPhoto = rd.RoomPhotos[j];

                            mtl.Set <RoomsPhotosBridge>().Add(rpb);

                            //rd.Rooms[i].RoomsPhotosBridges.Clear();
                            //rd.RoomPhotos[j].RoomsPhotosBridges.Clear();

                            rd.Rooms[i].RoomsPhotosBridges.Add(rpb);
                            rd.RoomPhotos[j].RoomsPhotosBridges.Add(rpb);
                        }
                    }
                    Room r = mtl.Rooms.ToList().Last();
                    if (r != null)
                    {
                        rd.Rooms[0].RoomSequence = r.ID + 1;
                        rd.Rooms[1].RoomSequence = r.ID + 1;
                    }
                    else
                    {
                        rd.Rooms[0].RoomSequence = 0;
                        rd.Rooms[1].RoomSequence = 0;
                    }


                    foreach (Room room in rd.Rooms)
                    {
                        mtl.Set <Room>().Add(room);
                    }
                    foreach (RoomPhoto photo in rd.RoomPhotos)
                    {
                        mtl.Set <RoomPhoto>().Add(photo);
                    }
                    mtl.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw;
                }

                return(RedirectToAction("roomslist"));
            }
            else
            {
                return(RedirectToAction("index"));
            }
        }