public ActionResult Create(CreateAssignmentViewModel newAssignment, int id) { newAssignment.courseID = id; if (aService.createAssignment(newAssignment)) { return(RedirectToAction("Index", "Assignments", new { id = id })); } else { ModelState.AddModelError("", "Could not add the assignment!"); return(RedirectToAction("Create", "Assignments")); } }
public ActionResult CreateFromProject(Guid id) { var projects = _projectService.GetAllByUserId(User.Identity.GetUserId()); var model = new CreateAssignmentViewModel { Assignment = new Assignment(), ListOfProjects = new SelectList(projects, "Id", "Name", id), 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(id), "Id", "UserName", User.Identity.GetUserId()), ListOfSprints = new SelectList(projects.First(x => x.Id == id).Sprints, "Id", "Name") }; return(View("Create", model)); }
// Add assignment to db.assignments public bool createAssignment(CreateAssignmentViewModel newAssignment) { Assignment temp = new Assignment() { name = newAssignment.name, solution = newAssignment.solution, description = newAssignment.description, startDate = newAssignment.startDate, endDate = newAssignment.endDate }; db.Assignments.Add(temp); db.SaveChanges(); AssignmentsInCourse link = new AssignmentsInCourse() { assignmentID = temp.ID, courseID = newAssignment.courseID }; db.AssingmentInCourse.Add(link); return(Convert.ToBoolean(db.SaveChanges())); }
public ActionResult Create() { var projects = _projectService.GetAllByUserId(User.Identity.GetUserId()); if (!projects.Any()) { return(RedirectToAction("Dashboard", "Manager")); } var model = new CreateAssignmentViewModel { Assignment = new 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().Sprints, "Id", "Name") }; return(View(model)); }
public void testCreateAssignment() { // arrange var a1 = new CreateAssignmentViewModel { name = "Mooshak 2.0", description = "Make Mooshak free for us", startDate = new DateTime(2016, 05, 05, 00, 00, 00), endDate = new DateTime(2016, 06, 06, 23, 59, 59), solution = "free" }; // act var beforeadd = _service.getAllAssignments(); var result = _service.createAssignment(a1); var afteradd = _service.getAllAssignments(); // assert Assert.AreEqual(6, beforeadd.assignments.Count); Assert.AreEqual(7, afteradd.assignments.Count); }
public IActionResult Create(CreateAssignmentViewModel Model) { EventManager EventManager = new EventManager(_UserManager.GetUserEmail(this.User), _UserManager, _Context); if (Model.Date.CompareTo(DateTime.Now) < 0) { @ViewBag.Error = "Please insert a date ahead from today."; this._LoadCreateData(); return(View(Model)); } int NewClassification = EventManager.ReClassifyConsult(); if (NewClassification != Model.Classification) { Model.Classification = NewClassification; @ViewBag.Error = "The consult had to be reclassified due to constraints."; } try { if (ModelState.IsValid) { Model.MedicKey = this._AttachMedicKey(Model.SelectedMedicKey); Model.PatientKey = this._AttachPatientKey(Model.SelectedPatientKey); Consults Consult = Mapper.Map <Consults>(Model); _Context.Add(Consult); _Context.SaveChanges(); @ViewBag.Success = "The Assignment has been created successfully!"; return(RedirectToAction("Agenda", "Agenda")); } } catch (Exception e) { Console.Write(e); @ViewBag.Error = "An internal error occurred."; this._LoadCreateData(); return(View(Model)); } return(View()); }
public CreateAssignmentPage() { InitializeComponent(); BindingContext = new CreateAssignmentViewModel(); }