Пример #1
0
        //[Authorize(Roles = "Admin,Client")]
        public ActionResult MyJobOrders(string Id, string JobOrderStatus, string clientId, bool IsClientView, string Status, string UpdatedBy, string JobOrderNumber, DateTime?CompletedOn, int JobOrderTypeId = 0, string UserAction = "Add")
        {
            UserViewModel 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;

            ViewBag.UserId          = userDetail.UserId;
            ViewData["Content"]     = cmsMgr.GetJobOrderAttachments(JobOrderNumber);
            ViewData["FinalAttach"] = cmsMgr.GetJobOrderFinalAttachments(JobOrderNumber);
            PopulateStatus(JobOrderStatus);
            PopulateOrderType(userDetail.SubscriberId, JobOrderTypeId);
            PopulateClient(userDetail.SubscriberId, clientId);
            //If Client has team members with all rights
            if (userDetail.CorporateId != null && userDetail.CorporateId != userDetail.SubscriberId)
            {
                userDetail.UserId = userDetail.CorporateId;
            }
            if (!string.IsNullOrEmpty(Id) && !string.IsNullOrEmpty(Status))
            {
                if (userDetail.DepartmentId == "ADI")
                {
                    //Jobs = Jobs.Where(c => c.JobOrderTypeId == JobOrderTypeId && c.JobOrderStatus == JobOrderStatus).ToList();
                    UpdatedBy = User.Identity.GetUserId();
                    if (Status == "Completed")
                    {
                        cmsMgr.UpdateJobStatus(userDetail.SubscriberId, Id, Status, DateTime.Now, UpdatedBy, DateTime.Now);
                    }
                    else
                    {
                        cmsMgr.UpdateJobStatus(userDetail.SubscriberId, Id, Status, DateTime.Now, UpdatedBy, null);
                    }
                }
            }
            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);
                }
            }

            if (IsClientView)
            {
                userDetail.UserId = userDetail.UserId;
            }
            else
            {
                userDetail.UserId = userDetail.SubscriberId;
            }

            var Jobs = cmsMgr.GetJobOrders(userDetail.UserId, IsClientView);

            if (!string.IsNullOrEmpty(clientId))
            {
                Jobs = Jobs.Where(c => c.ClientId == clientId).ToList();
            }

            if (!string.IsNullOrEmpty(JobOrderStatus))
            {
                Jobs = Jobs.Where(c => c.JobOrderStatus == JobOrderStatus).ToList();
            }

            if (JobOrderTypeId != 0)
            {
                Jobs = Jobs.Where(c => c.JobOrderTypeId == JobOrderTypeId).ToList();
            }

            return(View(Jobs));
        }