Exemplo n.º 1
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            TaskAssignment taskAssignment = db.TaskAssignments.Find(id);

            if (taskAssignment == null)
            {
                return(HttpNotFound());
            }

            TaskAssignmentViewModel model = new TaskAssignmentViewModel
            {
                TaskAssignmentId = taskAssignment.TaskAssignmentId,
                TaskName         = taskAssignment.TaskName,
                Description      = taskAssignment.Description,
                Deadline         = taskAssignment.Deadline,
                Status           = taskAssignment.Status,
                Priority         = taskAssignment.Priority,
                AssignmentDate   = taskAssignment.AssignmentDate,
                IsCompleted      = taskAssignment.IsCompleted,
                EventProject     = taskAssignment.EventProject.Name,
                AnyEmployee      = taskAssignment.AnyEmployee.FullName,
                Employee         = taskAssignment.Employee.FullName,
            };

            ViewBag.EventProjectId          = new SelectList(db.EventProjects, "EventProjectId", "Name");
            ViewBag.EmployeeId              = new SelectList(db.Employees, "Id", "FullName");
            ViewBag.ClientServiceEmployeeId = new SelectList(db.Employees, "Id", "FullName");

            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult Edit(int id, TaskAssignmentViewModel model)
        {
            if (ModelState.IsValid)
            {
                var taskAssignment = db.TaskAssignments.Find(id);
                if (taskAssignment == null)
                {
                    return(HttpNotFound());
                }

                taskAssignment.TaskName                = model.TaskName;
                taskAssignment.Description             = model.Description;
                taskAssignment.Deadline                = model.Deadline;
                taskAssignment.Status                  = TaskAssignment.TaskStatus.Pending;
                taskAssignment.Priority                = model.Priority;
                taskAssignment.AssignmentDate          = DateTime.Now;
                taskAssignment.IsCompleted             = model.IsCompleted;
                taskAssignment.EmployeeId              = model.EmployeeId;
                taskAssignment.ClientServiceEmployeeId = User.Identity.GetUserId <int>();
                taskAssignment.EventProjectId          = model.EventProjectId;

                db.Entry(taskAssignment).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("AllTasksIndex"));
            }
            ViewBag.EventProjectId          = new SelectList(db.EventProjects, "EventProjectId", "Name");
            ViewBag.EmployeeId              = new SelectList(db.Employees, "Id", "FullName");
            ViewBag.ClientServiceEmployeeId = new SelectList(db.Employees, "Id", "FullName");

            return(View());
        }
Exemplo n.º 3
0
        /// <summary>
        /// This action gets the a task assignment's details
        /// </summary>
        /// <param name="id">task assignment id</param>
        /// <returns>details view</returns>
        // GET: TaskAssignment/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            TaskAssignment taskAssignment = db.TaskAssignments.Find(id);

            if (taskAssignment == null)
            {
                return(HttpNotFound());
            }

            var model = new TaskAssignmentViewModel
            {
                TaskAssignmentId = taskAssignment.TaskAssignmentId,
                TaskName         = taskAssignment.TaskName,
                Description      = taskAssignment.Description,
                Deadline         = taskAssignment.Deadline,
                Status           = taskAssignment.Status,
                Priority         = taskAssignment.Priority,
                AssignmentDate   = taskAssignment.AssignmentDate,
                IsCompleted      = taskAssignment.IsCompleted,
                //EmployeeTask = taskAssignment.EmployeeTask.TaskName,
                EventProject = taskAssignment.EventProject.Name,
                AnyEmployee  = taskAssignment.AnyEmployee.FullName,
                Employee     = taskAssignment.Employee.FullName,
            };

            return(View(model));
        }
Exemplo n.º 4
0
        public ActionResult Assign(int?id)
        {
            var model = new TaskAssignmentViewModel();

            model.EventProjectId = id ?? default(int);

            ViewBag.EventProjectId          = new SelectList(db.EventProjects, "EventProjectId", "Name");
            ViewBag.EmployeeId              = new SelectList(db.Employees, "Id", "FullName");
            ViewBag.ClientServiceEmployeeId = new SelectList(db.Employees, "Id", "FullName");
            return(View(model));
        }
Exemplo n.º 5
0
        public ActionResult Assign(TaskAssignmentViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.Deadline < DateTime.Now.AddHours(2) && model.Deadline < DateTime.Today)
                {
                    ModelState.AddModelError("Deadline", "The deadline should not be older day and less than 2 hours from now.");

                    ModelState.AddModelError(String.Empty, "Issue with the deadline");

                    return(View(model));
                }

                var taskAssignment = new TaskAssignment
                {
                    TaskName                = model.TaskName,
                    Description             = model.Description,
                    Deadline                = model.Deadline,
                    Status                  = TaskAssignment.TaskStatus.Pending,
                    Priority                = model.Priority,
                    AssignmentDate          = DateTime.Now,
                    IsCompleted             = model.IsCompleted,
                    EmployeeId              = model.EmployeeId,
                    ClientServiceEmployeeId = User.Identity.GetUserId <int>(),
                    EventProjectId          = model.EventProjectId,
                };

                db.TaskAssignments.Add(taskAssignment);
                db.SaveChanges();

                ViewBag.EventProjectId          = new SelectList(db.EventProjects, "EventProjectId", "Name");
                ViewBag.EmployeeId              = new SelectList(db.Employees, "Id", "FullName");
                ViewBag.ClientServiceEmployeeId = new SelectList(db.Employees, "Id", "FullName");

                return(RedirectToAction("AllTasksIndex"));
                //return RedirectToAction("Details", new { id = taskAssignment.TaskAssignmentId });
            }
            else
            {
                ViewBag.EventProjectId          = new SelectList(db.EventProjects, "EventProjectId", "Name");
                ViewBag.EmployeeId              = new SelectList(db.Employees, "Id", "FullName");
                ViewBag.ClientServiceEmployeeId = new SelectList(db.Employees, "Id", "FullName");
                return(View());
            }
        }