public void EditASession_ShouldReturnExpected() { var sessionToEdit = _sessionManager.GetSessionById(1); sessionToEdit.Name = "EDITEDSESSIONNAME"; _sessionManager.EditSession(sessionToEdit); Assert.AreEqual("EDITEDSESSIONNAME", _sessionManager.GetSessionById(1).Name); }
public ActionResult EditSessionPost(EditSessionViewModel inputVm) { if (inputVm == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var sessionToUpdate = _sessionManager.GetSessionByIdWithIncludes(inputVm.SessionId); try { int?location = _utilitiesManager.GetIdForLocationOrCreateIfNotExists(inputVm.NameOfLocation); int?hrPerson = inputVm.HrPerson; sessionToUpdate.Name = inputVm.NameOfSession; sessionToUpdate.ActivityId = inputVm.Activity.Id; sessionToUpdate.StartDate = inputVm.StartDate; sessionToUpdate.EndDate = inputVm.EndDate; sessionToUpdate.Description = inputVm.Description; sessionToUpdate.IsOpenForExpressionOfInterest = inputVm.IsOpenForExpressionOfInterest; sessionToUpdate.LocationId = location; sessionToUpdate.HrPersonId = hrPerson; _sessionManager.EditSession(sessionToUpdate); return(RedirectToAction("SessionForActivity", "ActivitySummary", new { id = sessionToUpdate.Id })); //ModelState.AddModelError("NameOfSession", "Aktiviteten existerar redan."); } catch (RetryLimitExceededException /* dex */) { ModelState.AddModelError("", "Det går inte att spara ändringarna. Försök igen, och om problemet kvarstår se systemadministratören ."); } ViewBag.AllHrPersons = new SelectList(_personManager.GetAllHrPersons().OrderBy(n => n.FirstName), "Id", "FullName", sessionToUpdate.HrPersonId); ViewBag.AllActivities = new SelectList(_activityManager.GetAllActivities().OrderBy(n => n.Name), "Id", "Name", sessionToUpdate.ActivityId); ViewBag.NameOfLocation = inputVm.NameOfLocation; inputVm.AddedTags = _utilitiesManager.GetAllTagsForSessionById(inputVm.SessionId).ToList(); return(View("EditSession", inputVm)); }