Exemplo n.º 1
0
 public IActionResult Delete(int?id)
 {
     if (id != null)
     {
         _courseService.DeleteCourse((int)id);
         _assignmentService.DeleteAssignment((int)id);
         return(RedirectToAction(nameof(Index)));
     }
     return(Content(""));
 }
        public async Task <ActionResult> DeleteAssignment(Guid groupId, Guid assignmentId)
        {
            var command = new DeleteAssignment
            {
                UserId       = User.GetUserId(),
                GroupId      = groupId,
                AssignmentId = assignmentId
            };
            await _assignmentService.DeleteAssignment(command);

            return(Ok());
        }
Exemplo n.º 3
0
 public void DeleteAssignment(string id, string modifiedBy, DateTime lastModification)
 {
     try {
         _assignmentService.DeleteAssignment(id, modifiedBy, lastModification);
     } catch (Exception ex) {
         Log.Write(ex);
         throw;
     }
 }
Exemplo n.º 4
0
        public async Task <ActionResult> Delete(int id)
        {
            var assignment = await db.GetAssignmentIdAsync(id);

            db.DeleteAssignment(assignment);
            await db.SaveChangesAsync();

            return(Json(new { success = true, message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> DeleteAssignment([FromBody] AssignmentRequest request)
        {
            Assignment temp = _mapper.Map <Assignment>(request);

            if (await _assignmentService.DeleteAssignment(temp))
            {
                return(Ok("Successful"));
            }
            return(BadRequest("False"));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> DeleteAssignment(int assignmentId)
        {
            ServiceResponse <string> response = await _assignmentService.DeleteAssignment(new DeleteAssignmentDto { AssignmentId = assignmentId });

            if (response.Success)
            {
                return(Ok(response));
            }
            return(NotFound(response));
        }
Exemplo n.º 7
0
        public async Task <IActionResult> DeleteAssignment(int id)
        {
            ServiceResponse <List <GetAssignmentDto> > response = await _assignmentService.DeleteAssignment(id);

            ViewBag.Team = new SelectedList();
            if (response.Data == null)
            {
                return(NotFound(response));
            }
            return(Ok(response));
        }
Exemplo n.º 8
0
        public HttpResponseMessage Delete(int labNumber, string name)
        {
            var assignment = _assignmentService.GetByLabAndName(labNumber, name);

            if (assignment == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }
            else
            {
                _assignmentService.DeleteAssignment(assignment);
                return(Request.CreateResponse(HttpStatusCode.OK));
            }
        }
        public async Task <IActionResult> DeleteAssignment(Guid id)
        {
            AppUser currentUser = _userManager.GetUserAsync(User).Result;
            Guid    TeamId      = await _assignmentService.GetTeamByAssignmentId(id);

            Assignment assignment = await _assignmentService.GetAssignmentById(id);

            await _assignmentService.DeleteAssignment(assignment);

            if (await _userManager.IsInRoleAsync(currentUser, "Manager"))
            {
                return(RedirectToAction("GetTeamAssignmentList", "Assignment", new { TeamId }));
            }
            return(RedirectToAction("GetAllAssignments"));
        }
 public ActionResult Delete(int id)
 {
     _assignmentsService.DeleteAssignment(id);
     return(RedirectToAction("Index"));
 }
Exemplo n.º 11
0
        public async Task <ServiceResponse <string> > RemoveCourse(int courseId)
        {
            ServiceResponse <string> serviceResponse = new ServiceResponse <string>();

            Course dbCourse = await _context.Courses
                              .Include(c => c.Instructors).ThenInclude(cs => cs.User)
                              .Include(c => c.Sections)
                              .Include(c => c.Assignments)
                              .Include(c => c.PeerGradeAssignment)
                              .FirstOrDefaultAsync(c => c.Id == courseId);

            if (dbCourse == null)
            {
                serviceResponse.Success = false;
                serviceResponse.Message = "Course not found.";
                return(serviceResponse);
            }

            if (!dbCourse.Instructors.Any(c => c.UserId == GetUserId()))
            {
                serviceResponse.Success = false;
                serviceResponse.Message = "User does not have authority on this course to remove the course.";
                return(serviceResponse);
            }

            _context.PeerGradeAssignments.Remove(dbCourse.PeerGradeAssignment);

            foreach (var i in dbCourse.Instructors)
            {
                _context.CourseUsers.Remove(i);
            }

            foreach (var i in dbCourse.Assignments)
            {
                await _assignmentService.DeleteWithForce(i.Id);

                await _assignmentService.DeleteAssignment(new DeleteAssignmentDto
                {
                    AssignmentId = i.Id
                });
            }

            foreach (var i in dbCourse.Sections)
            {
                List <ProjectGroup> toBeDeletedGroups = await _context.ProjectGroups
                                                        .Where(c => c.AffiliatedSectionId == i.Id).ToListAsync();

                foreach (var j in toBeDeletedGroups)
                {
                    await _projectGroupService.DeleteProjectGroup(j.Id);
                }
            }
            _context.Sections.RemoveRange(dbCourse.Sections);

            _context.Courses.Remove(dbCourse);
            await _context.SaveChangesAsync();

            serviceResponse.Data    = "Successfully deleted the course";
            serviceResponse.Message = "Successfully deleted the course";
            return(serviceResponse);
        }
Exemplo n.º 12
0
        public async Task <IHttpActionResult> DeleteAssignment(AssignmentModel Model)
        {
            ExecuteResult Result = (await _AssignmentService.DeleteAssignment(Model));

            return(Json(Result));
        }
 public void Delete(int id)
 {
     assignmentService.DeleteAssignment(id);
 }
Exemplo n.º 14
0
 public void Delete(int id)
 {
     assignmentService.DeleteAssignment(assignmentService.GetById(id));
 }