Beispiel #1
0
        // GET: Home
        public ActionResult Index()
        {
            PublicVM pageContent = GetPageContent("Home", true, "public");

            pageContent.eventList = (from c in pageContent.eventList
                                     orderby c.EventDate
                                     orderby c.StartTime
                                     select c).ToList();
            return(View(pageContent));
        }
Beispiel #2
0
        public ActionResult Contact()
        {
            PublicVM pageContent = GetPageContent("Contact", false, "");

            pageContent.textList = (from c in pageContent.textList
                                    orderby c.WebTextID
                                    select c).ToList();


            return(View(pageContent));
        }
Beispiel #3
0
        /// <summary>
        /// Updates the entity model with the changes, but does not save.
        /// </summary>
        /// <param name="publicVM">The publicVm instance</param>
        /// <param name="db">the database</param>
        /// <returns>(make use of this)</returns>
        public bool UpdateChanges(PublicVM publicVM, WASEntities db)
        {
            tbl_Document modDoc = SelectById(publicVM.Document_ID.ToString(), true);

            //maybe more elegant way to do this
            modDoc.Issue_DT    = publicVM.IssueDate;
            modDoc.Description = publicVM.Description;
            modDoc.Method      = publicVM.Method;
            modDoc.Originator  = publicVM.Originator;
            modDoc.Reason      = publicVM.Reason;
            modDoc.Recipient   = publicVM.Recipient;
            modDoc.Active_IND  = publicVM.Hidden;

            db.Entry(modDoc).State = System.Data.Entity.EntityState.Modified; //tags the row as one thats modifed and needs to be saved

            //should probably do some conditional check here to allow user to know if it actually got modified
            return(true);
        }
Beispiel #4
0
        //maybe add parameterized constructor
        //issue with specific computers (i.e. Rupinders) caching data that should have been updated
        //should check other computers and see if this issue is related to specific computer only
        public IEnumerable <PublicVM> SelectAll(string publicNumber, string role)
        {
            List <PublicVM> PublicVMList = new List <PublicVM>();

            int publicNumberInt;

            try
            {
                publicNumberInt = Int32.Parse(publicNumber); //should be able to be done in LINQ
                //technically user never inputs this, provided by code from Client Id
                //should not have an issue with an exception here then
            }
            catch (FormatException e)
            {
                FormatException exception = new FormatException("Public Number must be a positive integer", e);
                exception.HelpLink          = "Please check over the provided information and try again.";
                exception.Data["Public ID"] = publicNumber;

                throw exception;
            }
            catch (InvalidOperationException e)
            {
                InvalidOperationException exception = new InvalidOperationException("There was an issue connecting to the database", e);
                exception.HelpLink = "Please contact Support through ServiceNow.";

                throw exception;
            }
            catch (Exception e) {
                //maybe write more here
                throw new Exception("There seems to be an issue.", e);
            }

            //refactor this into a more efficient conditional
            if (role == "Admin")
            {
                var documentList = (from d in _db.tbl_Document.AsNoTracking() //.AsNoTracking reduces resources by making this read only
                                    join f in _db.tbl_Folder.AsNoTracking() on d.Folder_ID equals f.Folder_ID
                                                                              //left outer join b/c not every document will have a reference number right away (aka no docreference)
                                    join dr in _db.tbl_DocReference.AsNoTracking() on d.Document_ID equals dr.Document_ID into ps
                                    join dt in _db.tbl_DocumentType.AsNoTracking() on d.DocumentType_ID equals dt.DocumentType_ID
                                    join cat in _db.tbl_Category.AsNoTracking() on dt.Category_ID equals cat.Category_ID
                                    where d.Folder_ID == publicNumberInt
                                    where d.DocumentNumber != null
                                    where cat.Category_ID != 6
                                    from dr in ps.DefaultIfEmpty()
                                    select new
                {
                    f.Folder_ID,
                    d.Document_ID,
                    dt.DocumentType_ID,
                    DtName = dt.Name,
                    d.Issue_DT,
                    d.Description,
                    cat.Category_ID,
                    CatName = cat.Name,
                    dr.Date1_DT,
                    dr.RefNumber,
                    dr.RefNumberType_CD,
                    d.FileExtension,
                    d.Method,
                    d.Originator,
                    d.Reason,
                    dr.Number1,
                    d.Recipient,
                    dol = d.tbl_DocReference.Where(e => e.RefNumberType_CD == "Claim").FirstOrDefault().Date1_DT,
                    claim = d.tbl_DocReference.Where(e => e.RefNumberType_CD == "Claim").FirstOrDefault().RefNumber,
                    archiveTime = d.LastUser_DT,
                    d.Active_IND                     //only want recipient and active_ind for admin, wonder if better way to do this
                }).ToList();

                if (!documentList.Any())
                {
                    throw new ArgumentException("This client does not exist or has no available records.");
                }

                foreach (var item in documentList)
                {
                    PublicVM objpvm = new PublicVM();

                    objpvm.Folder_ID        = item.Folder_ID;
                    objpvm.Document_ID      = item.Document_ID;
                    objpvm.DocumentType_ID  = item.DocumentType_ID;
                    objpvm.DocumentTypeName = item.DtName;
                    objpvm.IssueDate        = item.Issue_DT;
                    objpvm.Description      = item.Description;
                    objpvm.Category_ID      = item.Category_ID;
                    objpvm.CategoryName     = item.CatName;
                    objpvm.EffectiveDate    = item.Date1_DT;
                    objpvm.RefNumber        = item.RefNumber;
                    objpvm.ReferenceType    = item.RefNumberType_CD;
                    objpvm.FileExtension    = item.FileExtension.ToLower();
                    objpvm.Method           = item.Method;
                    objpvm.Originator       = item.Originator;
                    objpvm.Reason           = item.Reason;
                    objpvm.Supplier         = item.Number1;
                    objpvm.Recipient        = item.Recipient;
                    objpvm.DateOfLoss       = item.dol;
                    objpvm.Hidden           = item.Active_IND;
                    objpvm.ClaimNumber      = item.claim;
                    objpvm.ArchiveTime      = item.archiveTime.Ticks;

                    PublicVMList.Add(objpvm);
                }
            }
            else
            {
                var documentList = (from d in _db.tbl_Document.AsNoTracking() //.AsNoTracking reduces resources by making this read only
                                    join f in _db.tbl_Folder.AsNoTracking() on d.Folder_ID equals f.Folder_ID
                                                                              //left outer join b/c not every document will have a reference number right away (aka no docreference)
                                    join dr in _db.tbl_DocReference.AsNoTracking() on d.Document_ID equals dr.Document_ID into ps
                                    join dt in _db.tbl_DocumentType.AsNoTracking() on d.DocumentType_ID equals dt.DocumentType_ID
                                    join cat in _db.tbl_Category.AsNoTracking() on dt.Category_ID equals cat.Category_ID
                                    where d.Folder_ID == publicNumberInt
                                    where d.Active_IND == true //should only show active records, hide soft deleted ones
                                    where cat.Category_ID != 6 //Ramin said the System category records can be omitted from system
                                    from dr in ps.DefaultIfEmpty()
                                    select new
                {
                    f.Folder_ID,
                    d.Document_ID,
                    dt.DocumentType_ID,
                    DtName = dt.Name,
                    d.Issue_DT,
                    d.Description,
                    cat.Category_ID,
                    CatName = cat.Name,
                    dr.Date1_DT,
                    dr.RefNumber,
                    dr.RefNumberType_CD,
                    d.FileExtension,
                    d.Method,
                    d.Originator,
                    d.Reason,
                    dr.Number1,
                    dol = d.tbl_DocReference.Where(e => e.RefNumberType_CD == "Claim").FirstOrDefault().Date1_DT,
                    claim = d.tbl_DocReference.Where(e => e.RefNumberType_CD == "Claim").FirstOrDefault().RefNumber,
                    archiveTime = d.LastUser_DT
                }).ToList();

                if (!documentList.Any())
                {
                    throw new System.ArgumentException("This client does not exist or has no available records.");
                }

                foreach (var item in documentList)
                {
                    PublicVM objpvm = new PublicVM();

                    objpvm.Folder_ID        = item.Folder_ID;
                    objpvm.Document_ID      = item.Document_ID;
                    objpvm.DocumentType_ID  = item.DocumentType_ID;
                    objpvm.DocumentTypeName = item.DtName;
                    objpvm.IssueDate        = item.Issue_DT;
                    objpvm.Description      = item.Description;
                    objpvm.Category_ID      = item.Category_ID;
                    objpvm.CategoryName     = item.CatName;
                    objpvm.EffectiveDate    = item.Date1_DT;
                    objpvm.RefNumber        = item.RefNumber;
                    objpvm.ReferenceType    = item.RefNumberType_CD;
                    objpvm.FileExtension    = item.FileExtension.ToLower();
                    objpvm.Method           = item.Method;
                    objpvm.Originator       = item.Originator;
                    objpvm.Reason           = item.Reason;
                    objpvm.Supplier         = item.Number1;
                    objpvm.DateOfLoss       = item.dol;
                    objpvm.ClaimNumber      = item.claim;
                    objpvm.ArchiveTime      = item.archiveTime.Ticks;

                    PublicVMList.Add(objpvm);
                }
            }

            return(PublicVMList);
        }
Beispiel #5
0
        private PublicVM GetPageContent(string pageName, bool getVideo, string getEvents)
        {
            PublicVM pageContent = new PublicVM();

            if (getEvents == "public")
            {
                pageContent.eventList = (from ev in db.Events
                                         where ev.Type == "public"
                                         select ev).ToList();

                foreach (Event e in pageContent.eventList.ToList())
                {
                    if (compareDates(e.EventDate) != true)
                    {
                        pageContent.eventList.Remove(e);
                    }
                }

                if (pageContent.eventList.Count() == 0)
                {
                    Event noUpcomingEvents = new Event {
                        EventTitle = "No Upcoming Events, Please Check Back", Description = "", EventDate = DateTime.Today, StartTime = "0000"
                    };
                    pageContent.eventList.Add(noUpcomingEvents);
                }
            }
            if (getEvents == "team")
            {
                pageContent.eventList = (from ev in db.Events
                                         where ev.Type == "team"
                                         select ev).ToList();
            }



            if (getVideo == true)
            {
                Video currentVideo = new Video();
                currentVideo.Title = "invalid";
                currentVideo.URL   = "invalid";
                if (db.CurrentVideo.Count() > 0)
                {
                    currentVideo = db.CurrentVideo.Include("CurrentVideo").FirstOrDefault().CurrentVideo;
                }

                pageContent.currentVideo = currentVideo;
            }

            if (pageName == "Application")
            {
                pageContent.application = (from a in db.Applications
                                           select a).FirstOrDefault();
            }

            pageContent.textList = (from s in db.WebTexts
                                    where s.Page == pageName
                                    select s).ToList();

            pageContent.imageList = (from i in db.WebImages
                                     where i.Page == pageName
                                     orderby i.Location
                                     select i).ToList();

            return(pageContent);
        }
Beispiel #6
0
        public ActionResult Application()
        {
            PublicVM pageContent = GetPageContent("Application", false, "");

            return(View(pageContent));
        }
Beispiel #7
0
        public ActionResult History()
        {
            PublicVM pageContent = GetPageContent("History", false, "");

            return(View(pageContent));
        }
        //add parameterized constructor

        public IEnumerable <PublicVM> SelectAll(string publicNumber, string role)
        {
            List <PublicVM> PublicVMList = new List <PublicVM>();

            int publicNumberInt;

            try {
                publicNumberInt = Int32.Parse(publicNumber); //should be able to be done in LINQ
            } catch {
                return(null);
            }

            if (role == "Admin")
            {
                var documentList = (from d in _db.tbl_Document.AsNoTracking() //.AsNoTracking reduces resources by making this read only
                                    join f in _db.tbl_Folder.AsNoTracking() on d.Folder_ID equals f.Folder_ID
                                                                              //left outer join b/c not every document will have a reference number right away (aka no docreference)
                                    join dr in _db.tbl_DocReference.AsNoTracking() on d.Document_ID equals dr.Document_ID into ps
                                    join dt in _db.tbl_DocumentType.AsNoTracking() on d.DocumentType_ID equals dt.DocumentType_ID
                                    join cat in _db.tbl_Category.AsNoTracking() on dt.Category_ID equals cat.Category_ID
                                    where d.Folder_ID == publicNumberInt
                                    //where d.Active_IND == true //should only show active records, hide soft deleted ones
                                    where d.DocumentNumber != null
                                    where cat.Category_ID != 6
                                    from dr in ps.DefaultIfEmpty()
                                    select new
                {
                    f.Folder_ID,
                    d.Document_ID,
                    dt.DocumentType_ID,
                    DtName = dt.Name,
                    d.Issue_DT,
                    d.Description,
                    cat.Category_ID,
                    CatName = cat.Name,
                    dr.Date1_DT,
                    dr.RefNumber,
                    dr.RefNumberType_CD,
                    d.FileExtension,
                    d.Method,
                    d.Originator,
                    d.Reason,
                    dr.Number1,
                    d.Recipient,
                    d.Active_IND                     //only want recipient and active_ind for admin, wonder if better way to do this
                }).ToList();

                if (!documentList.Any())
                {
                    throw new System.ArgumentException("This client does not exist or has no available records.");
                }

                foreach (var item in documentList)
                {
                    PublicVM objpvm = new PublicVM();

                    objpvm.Folder_ID        = item.Folder_ID;
                    objpvm.Document_ID      = item.Document_ID;
                    objpvm.DocumentType_ID  = item.DocumentType_ID;
                    objpvm.DocumentTypeName = item.DtName;
                    objpvm.IssueDate        = item.Issue_DT;
                    objpvm.Description      = item.Description;
                    objpvm.Category_ID      = item.Category_ID;
                    objpvm.CategoryName     = item.CatName;
                    objpvm.EffectiveDate    = item.Date1_DT;
                    objpvm.RefNumber        = item.RefNumber;
                    objpvm.ReferenceType    = item.RefNumberType_CD;
                    objpvm.FileExtension    = item.FileExtension;
                    objpvm.Method           = item.Method;
                    objpvm.Originator       = item.Originator;
                    objpvm.Reason           = item.Reason;
                    objpvm.Supplier         = item.Number1;
                    objpvm.Recipient        = item.Recipient;  //not sure to keep
                    objpvm.Hidden           = item.Active_IND; //not sure to keep

                    PublicVMList.Add(objpvm);
                }
            }
            else
            {
                var documentList = (from d in _db.tbl_Document.AsNoTracking() //.AsNoTracking reduces resources by making this read only
                                    join f in _db.tbl_Folder.AsNoTracking() on d.Folder_ID equals f.Folder_ID
                                                                              //left outer join b/c not every document will have a reference number right away (aka no docreference)
                                    join dr in _db.tbl_DocReference.AsNoTracking() on d.Document_ID equals dr.Document_ID into ps
                                    join dt in _db.tbl_DocumentType.AsNoTracking() on d.DocumentType_ID equals dt.DocumentType_ID
                                    join cat in _db.tbl_Category.AsNoTracking() on dt.Category_ID equals cat.Category_ID
                                    where d.Folder_ID == publicNumberInt
                                    where d.Active_IND == true //should only show active records, hide soft deleted ones
                                    where cat.Category_ID != 6 //Ramin said the System category records can be omitted from system
                                    from dr in ps.DefaultIfEmpty()
                                    select new
                {
                    f.Folder_ID,
                    d.Document_ID,
                    dt.DocumentType_ID,
                    DtName = dt.Name,
                    d.Issue_DT,
                    d.Description,
                    cat.Category_ID,
                    CatName = cat.Name,
                    dr.Date1_DT,
                    dr.RefNumber,
                    dr.RefNumberType_CD,
                    d.FileExtension,
                    d.Method,
                    d.Originator,
                    d.Reason,
                    dr.Number1
                }).ToList();

                if (!documentList.Any())
                {
                    throw new System.ArgumentException("This client does not exist or has no available records.");
                }

                foreach (var item in documentList)
                {
                    PublicVM objpvm = new PublicVM();

                    objpvm.Folder_ID        = item.Folder_ID;
                    objpvm.Document_ID      = item.Document_ID;
                    objpvm.DocumentType_ID  = item.DocumentType_ID;
                    objpvm.DocumentTypeName = item.DtName;
                    objpvm.IssueDate        = item.Issue_DT;
                    objpvm.Description      = item.Description;
                    objpvm.Category_ID      = item.Category_ID;
                    objpvm.CategoryName     = item.CatName;
                    objpvm.EffectiveDate    = item.Date1_DT;
                    objpvm.RefNumber        = item.RefNumber;
                    objpvm.ReferenceType    = item.RefNumberType_CD;
                    objpvm.FileExtension    = item.FileExtension;
                    objpvm.Method           = item.Method;
                    objpvm.Originator       = item.Originator;
                    objpvm.Reason           = item.Reason;
                    objpvm.Supplier         = item.Number1;

                    PublicVMList.Add(objpvm);
                }
            }

            return(PublicVMList);  //the missing ref data exists here
        }