/** public ActionResult createFolder(MapFolder parent)
         * {
         *   var id = User.Identity.GetUserId();
         *   ObjectId UserId = new ObjectId(id);
         *   MapFolder toadd = new MapFolder();
         *   toadd.Creator = UserId;
         * }**/


        public ActionResult MyFirstMapAndFolders()
        {
            try
            {
                var       id                = User.Identity.GetUserId();
                ObjectId  UserId            = new ObjectId(id);
                MapFolder superiorMapFolder = _mapFolderDataManager.GetSuperiorMapFolderOfUserOwned(UserId);
                if (superiorMapFolder == null)
                {
                    //  superiorMapFolder = createSuppFolderLocaly(OWNED_SUPIRIOR);
                    _mapFolderDataManager.AddFolder(superiorMapFolder);
                }
                var mapFolders = this._mapFolderDataManager.GetAllSubFolder(superiorMapFolder);

                //var mapFolders = this._mapFolderDataManager.GetFirstFoldersOfUser(UserId);
                var maps = this._mapFolderDataManager.GetAllMapsInFolder(superiorMapFolder);
                _mapDataManager    = new MapDB(new Settings());
                ViewBag.maps       = maps;
                ViewBag.currFolder = superiorMapFolder;
                return(PartialView("_MyFoldersView", mapFolders));
            }
            catch (Exception e)
            {
                string exp = e.ToString();
                //return RedirectToAction("Index", "Home");
                _mapDataManager = new MapDB(new Settings());
                ViewBag.maps    = _mapDataManager.GetAllMaps();
                return(PartialView("_MyFoldersView", new List <MapFolder>()));
            }
        }
Exemplo n.º 2
0
        public ActionResult Index(string id, string ownedOrShared)
        {
            //MailSender.SendMailMessage("*****@*****.**", "*****@*****.**", "", "", "(do not reply)", "lalalalalala");
            bool isOwned;
            bool isShared;

            ViewBag.isShared = ownedOrShared != null && ownedOrShared.Equals("shared");
            if (ownedOrShared == null)
            {
                isOwned  = false;
                isShared = false;
            }
            else
            {
                isOwned  = ownedOrShared.Equals("owned");
                isShared = ownedOrShared.Equals("shared");
            }
            ViewBag.ownedFolderID = null;
            MapFolderDB mapFolderManeger = new MapFolderDB(new Settings());
            bool        isIdOfOwned      = false;

            if (id != null)
            {
                ObjectId  oId = new ObjectId(id);
                MapFolder mf  = mapFolderManeger.GetMapFolderById(oId);
                if (isOwned)
                {
                    ViewBag.ownedFolderID = oId;
                    isIdOfOwned           = true;
                }
            }
            if (!isIdOfOwned)
            {
                ObjectId userID    = new ObjectId(User.Identity.GetUserId());
                var      supFolder = new MapFolderDB(new Settings()).GetSuperiorMapFolderOfUserOwned(userID);
                if (supFolder != null)
                {
                    ObjectId fId = supFolder.Id;
                    ViewBag.ownedFolderID = fId;
                }
                else
                {
                    supFolder = createSuppFolderLocaly(SharedCodedData.OWNED_SUPIRIOR);
                    mapFolderManeger.AddFolder(supFolder);
                    ObjectId fId = supFolder.Id;
                    ViewBag.ownedFolderID = fId;
                }
            }

            ViewBag.sharedFolderID = null;

            bool isIdOfShared = false;

            if (id != null)
            {
                ObjectId  oId = new ObjectId(id);
                MapFolder mf  = mapFolderManeger.GetMapFolderById(oId);
                if (isShared)
                {
                    ViewBag.sharedFolderID = oId;
                    isIdOfShared           = true;
                }
            }
            if (!isIdOfShared)
            {
                ObjectId userID    = new ObjectId(User.Identity.GetUserId());
                var      supFolder = new MapFolderDB(new Settings()).GetSuperiorMapFolderOfUserShared(userID);
                if (supFolder != null)
                {
                    ObjectId fId = supFolder.Id;
                    ViewBag.sharedFolderID = fId;
                }
                else
                {
                    supFolder = createSuppFolderLocaly(SharedCodedData.SHARED_SUPIRIOR);
                    mapFolderManeger.AddFolder(supFolder);
                    ObjectId fId = supFolder.Id;
                    ViewBag.sharedFolderID = fId;
                }
            }

            return(View());
        }