Example #1
0
        //[Authorize(Roles = "Admin,Client,Employee")]
        public ActionResult MyTasks(string Id, string TaskId, string AssignedTo, string JobOrderNumber, int JobOrderTypeId = 0, int StatusType = 0, short TaskStatus = -1, string UserAction = "Add")
        {
            string UserId      = User.Identity.GetUserId();
            var    userDetails = generic.GetUserDetail(User.Identity.GetUserId());

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

            ViewData["plandetail"]  = plandetail;
            ViewData["Attachment"]  = admin.GetTaskAttachments(TaskId);
            ViewData["FinalAttach"] = cmsMgr.GetTaskFinalAttachments(TaskId);
            PopulateTaskType(userDetails.SubscriberId, JobOrderTypeId);
            PopulateAssignedToList(UserId, AssignedTo);
            PopulateJobOrderlist(UserId, JobOrderNumber);
            PopulateTaskStatuslist(TaskStatus);
            if (!string.IsNullOrEmpty(TaskId))
            {
                foreach (string file in Request.Files)
                {
                    HttpPostedFileBase attachment = Request.Files[file] as HttpPostedFileBase;
                    cmsMgr.uploadTaskFile(TaskId, attachment);
                }
            }
            if (Id != null && TaskStatus > -1)
            {
                admin.UpdateTaskStatus(Id, TaskStatus, AssignedTo);
                AssignedTo = null;
                TaskStatus = -1;
            }

            //if (userDetails.DepartmentId == "ADI")
            //{
            var Tasks = admin.GetTaskFORAssignedTo(UserId);

            if (!string.IsNullOrEmpty(AssignedTo) && AssignedTo != "undefined")
            {
                Tasks = Tasks.Where(t => t.AssignedTo == AssignedTo).ToList();
            }
            if (!string.IsNullOrEmpty(JobOrderNumber) && JobOrderNumber != "undefined")
            {
                Tasks = Tasks.Where(t => t.JobOrderNumber == JobOrderNumber).ToList();
            }
            if (TaskStatus != -1)
            {
                Tasks = Tasks.Where(t => t.TaskStatus == TaskStatus).ToList();
            }
            if (JobOrderTypeId != 0)
            {
                Tasks = Tasks.Where(t => t.TaskTypeId == JobOrderTypeId).ToList();
            }
            if (UserAction == "Delete" && TaskId != null)
            {
                if (cmsMgr.RemoveTask(TaskId, userDetails.SubscriberId))
                {
                    admin.AddNotification(userDetails.SubscriberId, UserId, " has deleted Task: " + TaskId, "Task", TaskId, false, DateTime.Now);
                }
                ViewBag.Result = "Deleted";
            }
            return(View(Tasks));
            //}
            //else
            //{
            //    var Tasks = admin.GetTaskFORAssignedTo(UserId);

            //    if (!string.IsNullOrEmpty(AssignedTo) && AssignedTo != "undefined")
            //        Tasks = Tasks.Where(t => t.AssignedTo == AssignedTo).ToList();
            //    if (!string.IsNullOrEmpty(JobOrderNumber) && JobOrderNumber != "undefined")
            //        Tasks = Tasks.Where(t => t.JobOrderNumber == JobOrderNumber).ToList();
            //    if (TaskStatus != -1)
            //        Tasks = Tasks.Where(t => t.TaskStatus == TaskStatus).ToList();
            //    if (JobOrderTypeId != 0)
            //        Tasks = Tasks.Where(t => t.TaskTypeId == JobOrderTypeId).ToList();
            //    if (UserAction == "Delete" && TaskId != null)
            //    {
            //        if (cmsMgr.RemoveTask(TaskId, userDetails.SubscriberId))
            //        {
            //            admin.AddNotification(userDetails.SubscriberId, UserId, " has deleted Task: " + TaskId, "Task", TaskId, false, DateTime.Now);
            //        }
            //    }
            //    return View(Tasks);
            //}
        }