コード例 #1
0
        //[Authorize(Roles = "Admin,Client")]
        public ActionResult JobOrderDetails(string Id, string JobOrderNumber, string JobOrderStatus, string UpdatedBy, bool CV = true, string UserAction = "Add")
        {
            var UserDetail = generic.GetUserDetail(User.Identity.GetUserId());

            ViewData["UserProfile"] = UserDetail;
            ViewBag.UserId          = UserDetail.SubscriberId;
            ViewData["CompanyLogo"] = cmsMgr.GetCompanyLogo(UserDetail.SubscriberId).FirstOrDefault();
            var plandetail = admin.GetUserplanDetails(UserDetail.SubscriberId).Where(c => c.AddOnId == 3).FirstOrDefault();

            ViewData["plandetail"] = plandetail;
            //If Client has team members with all rights
            if (UserDetail.CorporateId != null && UserDetail.CorporateId != UserDetail.SubscriberId)
            {
                UserDetail.UserId = UserDetail.CorporateId;
            }

            var JOCommentsCount = new JOCommentsCount();

            ViewData["JobOrderItems"] = cmsMgr.GetJobOrderItems(Id).AsEnumerable();
            ViewData["JOComments"]    = cmsMgr.GetJOComments(Id);
            ViewData["JOReplies"]     = cmsMgr.GetJOReplies();
            ViewBag.userId            = UserDetail.UserId;
            ViewBag.JobOrderNumber    = Id;
            ViewBag.JobOrderStatus    = JobOrderStatus;
            ViewBag.IsClientView      = CV;
            JOCommentsCount           = cmsMgr.GetJOCommentsCount(Id);
            ViewBag.CommentsCount     = JOCommentsCount.TotalJOComments;
            ViewData["Content"]       = cmsMgr.GetJobOrderAttachments(Id).FirstOrDefault(); //(from i in udb.JobOrderAttachment.Where(i => i.JobOrderNumber == Id) select i).FirstOrDefault();
            ViewData["FinalAttach"]   = cmsMgr.GetJobOrderFinalAttachments(Id);
            if (UserAction == "Delete" && JobOrderNumber != null)
            {
                if (cmsMgr.RemoveJobOrder(JobOrderNumber, UserDetail.SubscriberId))
                {
                    admin.AddNotification(UserDetail.SubscriberId, UserDetail.UserId, " has deleted Job Order: " + JobOrderNumber, "JobOrderDelete", JobOrderNumber, false, DateTime.Now);
                }
                return(RedirectToAction("MyJobOrders", "JobOrder", new { area = "CMS", IsClientView = true }));
            }
            if (Id != null && JobOrderStatus != null)
            {
                UpdatedBy = User.Identity.GetUserId();
                cmsMgr.UpdateJobStatus(UserDetail.UserId, Id, JobOrderStatus, DateTime.Now, UpdatedBy, DateTime.UtcNow);
                return(RedirectToAction("MyJobOrders", "JobOrder", new { area = "CMS", IsClientView = false }));
            }
            else
            {
                return(View(cmsMgr.GetJobOrderByJONumber(Id)));
                //return View(cmsMgr.GetJobOrderDetails(UserId, Id, CV));
            }
        }