Exemplo n.º 1
0
        public ActionResult AssignQuickLinks()
        {
            QuickLinks ObjAS = new QuickLinks();
            List <DSRCManagementSystem.Models.QuickLinks> Links = new List <DSRCManagementSystem.Models.QuickLinks>();

            try
            {
                var userid = Convert.ToInt32(Session["UserID"].ToString());
                Links = (from p in db.ManageQuickLinks

                         where p.IsActive == true && p.UserID == userid
                         select new QuickLinks()
                {
                    path = p.IconPath,
                    QuickLinkID = p.QuickLinkID,
                    PageModuleID = p.PageModuleID,
                    DisplayName = p.DisplayName
                }).ToList();

                ObjAS.links = Links;
            }

            catch (Exception ex)
            {
                throw ex;
            }
            return(View(ObjAS));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> CreateQuickLink([FromRoute] int?projectId, [FromRoute] string slug, [FromBody] QuickLinkCreateDto quickLink)
        {
            if (quickLink == null)
            {
                return(BadRequest());
            }

            var project = await GetProject(projectId, slug);

            if (project == null)
            {
                return(NotFound());
            }

            var newQuickLink = new QuickLinks
            {
                HousingProjectId = project.ProjectId,
                Name             = quickLink.Name,
                ProjectId        = quickLink.ProjectId,
                DocumentId       = quickLink.DocumentId,
                UserId           = UserId,
                ExternalLink     = quickLink.ExternalLink
            };

            _db.QuickLinks.Add(newQuickLink);
            await _db.SaveChangesAsync();

            await _db.Entry(newQuickLink).Reference(q => q.Document).LoadAsync();

            await _db.Entry(newQuickLink).Reference(q => q.Project).LoadAsync();

            return(Ok(new QuickLinkShortDto(newQuickLink)));
        }
Exemplo n.º 3
0
        public ActionResult GetMenuForRole(QuickLinks Links)
        {
            int userId = Convert.ToInt32(Session["UserID"]);

            var links = (from p in db.ManageQuickLinks
                         join q in db.AssignQuickLinks on p.QuickLinkID equals q.QuickLinkID
                         where p.IsActive == true && q.UserID == userId && q.IsActive == true && p.UserID == userId
                         select new
            {
                QuickLinkId = p.QuickLinkID,
            }).ToList();


            return(Json(links, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
        public ActionResult EditLinks(int QuickLinkID)
        {
            var EditQuickLinks = new QuickLinks();

            var EditQuickLinkId = db.ManageQuickLinks.Where(q => q.QuickLinkID == QuickLinkID && q.IsActive == true).Select(r => r).FirstOrDefault();

            try
            {
                var userid = Convert.ToInt32(Session["UserID"].ToString());

                var modules = db.Modules.ToList();
                ViewBag.ModuleList = new SelectList(new[] { new Module()
                                                            {
                                                                PageModuleID = 0, ModuleName = "---Select---"
                                                            } }.Union(modules), "PageModuleID", "ModuleName", EditQuickLinkId.PageModuleID);

                if (EditQuickLinkId != null)
                {
                    EditQuickLinks.path = EditQuickLinkId.IconPath;

                    EditQuickLinks.PageModuleID = EditQuickLinkId.PageModuleID;
                    EditQuickLinks.ModuleName   = db.Modules.FirstOrDefault(q => q.PageModuleID == EditQuickLinkId.PageModuleID).ModuleName;
                    EditQuickLinks.DisplayName  = EditQuickLinkId.DisplayName;


                    if (EditQuickLinks.path != null)
                    {
                        string pathImage = HttpContext.Server.MapPath(EditQuickLinks.path.ToString().Replace("../../", "~/"));
                        EditQuickLinks.path = System.IO.File.Exists(pathImage) == true?EditQuickLinks.path.ToString() : @"..\..\UsersData\Logo\Images\No_Image.png";;
                    }
                    else
                    {
                        EditQuickLinks.path = @"..\..\UsersData\Logo\Images\No_Image.png";
                    }
                }
            }

            catch (Exception ex)
            {
                throw ex;
            }
            return(View(EditQuickLinks));
        }
Exemplo n.º 5
0
        public QuickLinkShortDto(QuickLinks quickLink)
        {
            if (quickLink != null)
            {
                QuickLinkId  = quickLink.QuickLinkId;
                ProjectId    = quickLink.ProjectId;
                DocumentId   = quickLink.DocumentId;
                UserId       = quickLink.UserId;
                ExternalLink = quickLink.ExternalLink;
                Name         = quickLink.Name;

                if (quickLink.Project != null)
                {
                    ProjectSlug = quickLink.Project.Slug;
                }

                if (quickLink.Document != null)
                {
                    DocumentSlug = quickLink.Document.Slug;
                }
            }
        }
Exemplo n.º 6
0
        public ActionResult AssignQuickLinks(QuickLinks AssignQuickLinks)
        {
            QuickLinks ObjAS = new QuickLinks();

            try
            {
                List <DSRCManagementSystem.Models.QuickLinks> Links = new List <DSRCManagementSystem.Models.QuickLinks>();
                var AddLinks = db.AssignQuickLinks.CreateObject();
                int userId   = Convert.ToInt32(Session["UserID"]);
                //var toInsert=null;
                //var toDelete;

                var newLinks = new List <Int32?>();
                newLinks = AssignQuickLinks.selectedQuickLinkId;

                var oldQuickLinks = db.AssignQuickLinks.Where(x => x.UserID == userId).Select(x => x.QuickLinkID).ToList();

                if (newLinks != null)
                {
                    var toInsert = newLinks.Except(oldQuickLinks).ToList();
                    var toDelete = oldQuickLinks.Except(newLinks).ToList();


                    if (toInsert != null)
                    {
                        foreach (var item in toInsert.Distinct())
                        {
                            var insertNew = new AssignQuickLink()
                            {
                                QuickLinkID = Convert.ToInt32(item),
                                UserID      = userId,
                                IsActive    = true,
                                ModBy       = userId,
                                ModDate     = DateTime.Now,
                            };

                            db.AssignQuickLinks.AddObject(insertNew);
                        }
                    }
                    if (toDelete != null)
                    {
                        foreach (var item in toDelete)
                        {
                            int quicklinkid = Convert.ToInt32(item);
                            var data        = (from d in db.AssignQuickLinks
                                               where d.UserID == userId && d.QuickLinkID == quicklinkid
                                               select d).FirstOrDefault();


                            db.AssignQuickLinks.DeleteObject(data);
                        }
                    }
                    db.SaveChanges();

                    Links = (from p in db.ManageQuickLinks

                             where p.IsActive == true && p.UserID == userId
                             select new QuickLinks()
                    {
                        path = p.IconPath,
                        QuickLinkID = p.QuickLinkID,
                        PageModuleID = p.PageModuleID,
                        DisplayName = p.DisplayName
                    }).ToList();

                    ObjAS.links = Links;
                }

                // added if selected list is null
                if (newLinks == null)
                {
                    var toDelete = oldQuickLinks.ToList();
                    if (toDelete != null)
                    {
                        foreach (var item in toDelete)
                        {
                            int quicklinkid = Convert.ToInt32(item);
                            var data        = (from d in db.AssignQuickLinks
                                               where d.UserID == userId && d.QuickLinkID == quicklinkid
                                               select d).FirstOrDefault();


                            db.AssignQuickLinks.DeleteObject(data);
                        }
                    }
                    db.SaveChanges();

                    Links = (from p in db.ManageQuickLinks

                             where p.IsActive == true && p.UserID == userId
                             select new QuickLinks()
                    {
                        path = p.IconPath,
                        QuickLinkID = p.QuickLinkID,
                        PageModuleID = p.PageModuleID,
                        DisplayName = p.DisplayName
                    }).ToList();

                    ObjAS.links = Links;
                }
            }
            catch (Exception Ex)
            {
                string actionName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                ExceptionHandlingController.ExceptionDetails(Ex, actionName, controllerName);
            }
            // return RedirectToAction("Index", "Home");
            return(RedirectToAction("QuickLinks", "QuickLinks")); // redirect to quicklinks page
        }
Exemplo n.º 7
0
 public Homepage(IWebDriver driver) : base(driver)
 {
     QuickLinks = new QuickLinks(Component);
 }
Exemplo n.º 8
0
        public ActionResult EditLinks(QuickLinks Links)
        {
            try
            {
                var    EditQuickLinks = db.ManageQuickLinks.Where(q => q.QuickLinkID == Links.QuickLinkID).Select(r => r).FirstOrDefault();
                var    httpPostedFile = HttpContext.Request.Files["UploadedImage"] as HttpPostedFileBase;
                string IconPath       = ConfigurationManager.AppSettings["MenuIconPath"].ToString();

                if (httpPostedFile != null)// added on 9/1/2016
                {
                    var CoverPhotoName = Path.GetFileName(httpPostedFile.FileName);
                    var FolderPath     = Server.MapPath(IconPath);
                    if (!Directory.Exists(FolderPath))
                    {
                        Directory.CreateDirectory(FolderPath);
                    }

                    //2-9-16
                    string        AllImages   = ".png;.jpg;.jpeg;.jfif;.bmp;.tif;.tiff;.gif;.icon";
                    List <string> lstimgTypes = new List <string>();
                    string[]      imgtypes    = AllImages.Split(';');
                    lstimgTypes.AddRange(imgtypes);
                    if (lstimgTypes.Contains(Path.GetExtension(CoverPhotoName).ToLower()) == false)
                    {
                        return(Json(new { Result = "NotImage" }, JsonRequestBehavior.AllowGet));
                    }


                    var   filepath = Server.MapPath(IconPath + "/" + CoverPhotoName);
                    Image image    = Image.FromStream(httpPostedFile.InputStream, true, true);


                    if ((image.Width < 30 || image.Height < 30))
                    {
                        return(Json(new { Result = "Invalid" }, JsonRequestBehavior.AllowGet));
                    }

                    else
                    {
                        var path = Path.Combine(Server.MapPath(IconPath), httpPostedFile.FileName);
                        image.Save(path);
                        EditQuickLinks.DisplayName  = Links.DisplayName;
                        EditQuickLinks.UserID       = Convert.ToInt32(Session["UserID"].ToString());
                        EditQuickLinks.PageModuleID = Links.PageModuleID;
                        EditQuickLinks.IconPath     = ConfigurationManager.AppSettings["MenuIconPath"].ToString() + CoverPhotoName;
                        EditQuickLinks.ModBy        = Convert.ToInt32(Session["UserID"].ToString());
                        EditQuickLinks.ModDate      = DateTime.Now;
                        db.SaveChanges();
                        return(Json("Success", JsonRequestBehavior.AllowGet));
                    }
                }
                //added on 9/1/2016
                else
                {
                    EditQuickLinks.DisplayName  = Links.DisplayName;
                    EditQuickLinks.UserID       = Convert.ToInt32(Session["UserID"].ToString());
                    EditQuickLinks.PageModuleID = Links.PageModuleID;
                    //EditQuickLinks.IconPath = ConfigurationManager.AppSettings["MenuIconPath"].ToString() + CoverPhotoName;
                    EditQuickLinks.ModBy   = Convert.ToInt32(Session["UserID"].ToString());
                    EditQuickLinks.ModDate = DateTime.Now;
                    db.SaveChanges();
                    return(Json("Success", JsonRequestBehavior.AllowGet));// added
                }
                // ends
            }
            catch (Exception ex)
            {
                string actionName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                ExceptionHandlingController.ExceptionDetails(ex, actionName, controllerName);
                return(Json("Failed", JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 9
0
        public ActionResult AddLinks(QuickLinks Links)
        {
            try
            {
                var    AddLinks       = db.ManageQuickLinks.CreateObject();
                var    userid         = Convert.ToInt32(Session["UserID"].ToString());
                var    httpPostedFile = HttpContext.Request.Files["UploadedImage"] as HttpPostedFileBase;
                string IconPath       = ConfigurationManager.AppSettings["MenuIconPath"].ToString();

                var CoverPhotoName = Path.GetFileName(httpPostedFile.FileName);
                var FolderPath     = Server.MapPath(IconPath);
                if (!Directory.Exists(FolderPath))
                {
                    Directory.CreateDirectory(FolderPath);
                }


                var pageID = db.ManageQuickLinks.Where(x => x.PageModuleID == Links.PageModuleID && x.IsActive == true && x.UserID == userid).ToList();

                //2-9-16
                string        AllImages   = ".png;.jpg;.jpeg;.jfif;.bmp;.tif;.tiff;.gif;.icon";
                List <string> lstimgTypes = new List <string>();
                string[]      imgtypes    = AllImages.Split(';');
                lstimgTypes.AddRange(imgtypes);
                if (lstimgTypes.Contains(Path.GetExtension(CoverPhotoName).ToLower()) == false)
                {
                    return(Json(new { Result = "NotImage" }, JsonRequestBehavior.AllowGet));
                }



                Image image = Image.FromStream(httpPostedFile.InputStream, true, true);
                if (pageID.Count > 0)
                {
                    return(Json(new { Result = "Exists" }, JsonRequestBehavior.AllowGet));
                }
                else if (image.Width < 30 || image.Height < 30)
                {
                    return(Json(new { Result = "Invalid" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    var path = Path.Combine(Server.MapPath(IconPath), httpPostedFile.FileName);
                    image.Save(path);
                    AddLinks.PageModuleID = Links.PageModuleID;
                    AddLinks.DisplayName  = Links.DisplayName;
                    AddLinks.UserID       = Convert.ToInt32(Session["UserID"].ToString());
                    AddLinks.IconPath     = ConfigurationManager.AppSettings["MenuIconPath"].ToString() + CoverPhotoName;
                    AddLinks.CreatedBy    = Convert.ToInt32(Session["UserID"].ToString());
                    AddLinks.CreatedDate  = DateTime.Now;
                    AddLinks.IsActive     = true;
                    db.ManageQuickLinks.AddObject(AddLinks);
                    db.SaveChanges();
                    return(Json("Success", JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                string actionName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                ExceptionHandlingController.ExceptionDetails(ex, actionName, controllerName);
                return(Json("Failed", JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 10
0
    //public GeneralSliderWindow subMenuToolbar;

    void Awake()
    {
        quickLinks = this;
    }