示例#1
0
        public ActionResult Edit(int id, EditAssignmentViewModel model)
        {
            var repository = new AssignedCourseRepository(context);

            try
            {
                if (ModelState.IsValid)
                {
                    var assignmentUpd = MapperHelper.Map <AssignedCourse>(model);
                    repository.Update(assignmentUpd);
                    context.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View(model));
                }
            }
            catch (Exception ex) {
                ViewBag.ErrorMessage = ex.Message;
                return(View(model));
            }

            return(View());
        }
        public ActionResult Edit(Guid id)
        {
            var projects = _projectService.GetAllByUserId(User.Identity.GetUserId());

            if (!projects.Any())
            {
                return(RedirectToAction("Dashboard", "Manager"));
            }

            Assignment assignment = _assignmentService.FindById(id);

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

            var model = new EditAssignmentViewModel
            {
                Assignment       = assignment,
                ListOfProjects   = new SelectList(projects, "Id", "Name"),
                ListOfCategories = new SelectList(_dictionaryService.GetCategories(), "Id", "Description"),
                ListOfPriorities = new SelectList(_dictionaryService.GetPriorities(), "Id", "Description"),
                ListOfStatuses   = new SelectList(_dictionaryService.GetStatuses(), "Id", "Description"),
                ListOfUsers      = new SelectList(_dictionaryService.GetUsers(projects.FirstOrDefault().Id), "Id", "UserName", User.Identity.GetUserId()),
                ListOfSprints    = new SelectList(projects.First(x => x.Id == assignment.ProjectId).Sprints, "Id", "Name")
            };

            return(View(model));
        }
        public async Task <IActionResult> EditAssignment(Guid AssignmentId, EditAssignmentViewModel model)
        {
            if (ModelState.IsValid)
            {
                Assignment assignment = await _assignmentService.GetAssignmentById(AssignmentId);

                AppUser currentUser = _userManager.GetUserAsync(User).Result;
                Guid    TeamId      = await _assignmentService.GetTeamByAssignmentId(AssignmentId);

                assignment.AssignmentName        = model.AssignmentName;
                assignment.AssignmentDescription = model.AssignmentDescription;
                assignment.AssignmentStatus      = model.AssignmentStatus;
                if (model.AssignmentStatus == CompletionStatus.Done)
                {
                    assignment.CompletedTime = DateTime.Now;
                }
                await _assignmentService.EditAssignment(assignment);

                if (await _userManager.IsInRoleAsync(currentUser, "Manager"))
                {
                    return(RedirectToAction("GetTeamAssignmentList", "Assignment", new { TeamId }));
                }
                return(RedirectToAction("GetAllAssignments"));
            }
            return(View(model));
        }
示例#4
0
        public async Task <ActionResult> Edit(int id, EditAssignmentViewModel model)
        {
            Assignment assignment = await db.Assignments.FindAsync(id);

            ApplicationUser au = db.Users.Find(HttpContext.User.Identity.GetUserId());

            if (!(au.OrganizerInProjects.Contains(assignment.Project) || au.MemberInProjects.Contains(assignment.Project) || UserManager.IsInRole(au.Id, "Administrator")))
            {
                TempData["Toast"] = new Toast
                {
                    Title = "Assignment",
                    Body  = "Access unauthorized!",
                    Type  = ToastType.Danger
                };
                return(RedirectToAction("Index", "Home"));
            }
            if (ModelState.IsValid)
            {
                assignment.Title       = model.Assignment.Title;
                assignment.Description = model.Assignment.Description;
                assignment.Status      = model.Assignment.Status;
                assignment.Assigner    = db.Users.Find(UserManager.FindByName(model.Assigner).Id);
                assignment.Assignee    = db.Users.Find(UserManager.FindByName(model.Assignee).Id);
                System.Diagnostics.Debug.WriteLine(assignment.Assigner.UserName);
                System.Diagnostics.Debug.WriteLine(assignment.Assignee.UserName);
                assignment.StartDate       = model.Assignment.StartDate;
                assignment.EndDate         = model.Assignment.EndDate;
                db.Entry(assignment).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Details", "Projects", new { id = assignment.Project.ProjectId }));
            }
            return(View(model));
        }
        public ActionResult Edit(EditAssignmentViewModel model)
        {
            if (ModelState.IsValid)
            {
                _assignmentService.Update(model.Assignment);
                return(RedirectToAction("Details", "Assignments", new { id = model.Assignment.Id }));
            }

            return(RedirectToAction("Edit", new { id = model.Assignment.Id }));
        }
示例#6
0
        public async Task <IActionResult> EditAssignment(EditAssignmentViewModel model, int assignmentId)
        {
            AssignmentDataService assignmentDataService = new AssignmentDataService(dbContext);
            Assignment            assignment            = assignmentDataService.GetAssignmentById(assignmentId);

            assignmentDataService.UpdateAssignment(model, assignment);

            await dbContext.SaveChangesAsync();

            return(RedirectToAction("Details", "Instructor", new { id = assignment.ClassId }));
        }
        public async Task <IActionResult> EditAssignment(Guid AssignmentId)
        {
            if (AssignmentId == null)
            {
                return(NotFound());
            }
            Assignment assignment = await _assignmentService.GetAssignmentById(AssignmentId);

            EditAssignmentViewModel model = new EditAssignmentViewModel()
            {
                TeamId                = await _assignmentService.GetTeamByAssignmentId(AssignmentId),
                AssignmentId          = assignment.AssignmentId,
                AssignmentName        = assignment.AssignmentName,
                AssignmentDescription = assignment.AssignmentDescription,
                AssignmentStatus      = assignment.AssignmentStatus
            };

            return(View(model));
        }
示例#8
0
        public void UpdateAssignment(EditAssignmentViewModel model, Assignment a)
        {
            a.Name        = model.Name;
            a.StartDate   = model.StartDate;
            a.EndDate     = model.EndDate;
            a.Description = model.Description;
            a.MemoryLimit = model.MemoryLimit;
            a.TimeLimit   = model.TimeLimit;
            a.ClassId     = model.ClassId;
            a.TestCases.RemoveAll(item => item.ID > 0);
            foreach (var item in model.TestCases)
            {
                item.AssignmentId = a.Id;
                a.TestCases.Add(item);
            }
            a.Languages = model.Languages;

            autoGraderDbContext.Assignments.Update(a);
        }
示例#9
0
 public ActionResult Edit(int id, EditAssignmentViewModel model)
 {
     try
     {
         var repository = new AssignedRepository(context);
         if (ModelState.IsValid)
         {
             var update = MapperHelpers.Map <AssignedCourse>(model);
             repository.Update(update);
             context.SaveChanges();
             return(RedirectToAction("Index"));
         }
         else
         {
             return(HttpNotFound());
         }
     }
     catch (Exception ex)
     {
         ViewBag.MessageError = ex.Message;
         return(View(model));
     }
 }
示例#10
0
        public IActionResult EditAssignment(int id)
        {
            AssignmentDataService assignmentDataService = new AssignmentDataService(dbContext);
            Assignment            assignment            = assignmentDataService.GetAssignmentById(id);

            EditAssignmentViewModel model = new EditAssignmentViewModel()
            {
                ClassId           = assignment.ClassId,
                Description       = assignment.Description,
                EndDate           = assignment.EndDate,
                StartDate         = assignment.StartDate,
                Languages         = assignment.Languages,
                MemoryLimit       = assignment.MemoryLimit,
                TimeLimit         = assignment.TimeLimit,
                Name              = assignment.Name,
                NumberOfTestCases = assignment.TestCases.Count,
                TestCases         = assignment.TestCases
            };

            ViewData["AssignmentId"] = assignment.Id;

            return(View(model));
        }
 public EditAssignmentPage(Assignment assignment)
 {
     InitializeComponent();
     BindingContext = new EditAssignmentViewModel(assignment);
 }