public void WhenModelIsSet_IsValidIsUpdated() { var vm = new ScheduleViewModel(); var model = new ScheduleEditMock(); var propertiesChanged = new List<string>(); model.MakeValid(); vm.PropertyChanged += (o, e) => propertiesChanged.Add(e.PropertyName); // Act. vm.Model = model; Assert.IsTrue(vm.IsValid); Assert.IsTrue(propertiesChanged.Any(p => p == "IsValid")); model = new ScheduleEditMock(); model.MakeInvalid(); propertiesChanged.Clear(); // Act. vm.Model = model; Assert.IsFalse(vm.IsValid); Assert.IsTrue(propertiesChanged.Any(p => p == "IsValid")); }
public void PropertiesTest() { TestsHelper.TestPublicPropertiesGetSet(new ScheduleViewModel()); // Test StartImmediately property. var vm = new ScheduleViewModel(); var model = new ScheduleEditMock(); vm.Model = model; vm.StartImmediately = true; Assert.IsNull(model.StartOn); vm.StartImmediately = false; Assert.IsNotNull(model.StartOn); vm.StartImmediately = true; Assert.IsNull(model.StartOn); // Test NoEndDate property. vm.Model = model; vm.NoEndDate = true; Assert.IsNull(model.EndOn); vm.NoEndDate = false; Assert.IsNotNull(model.EndOn); vm.NoEndDate = true; Assert.IsNull(model.EndOn); }
/// <summary> /// Maps the event definition into the the schedule view model. /// </summary> /// <param name="eventDefinition"></param> /// <returns></returns> public ScheduleViewModel Map(EventDefinition eventDefinition) { var times = GetTimes(eventDefinition); List<ScheduleSession> scheduleSessions = eventDefinition .Sessions.Select(s => new ScheduleSession { SessionId = s.SessionId, Title = s.Title, StartTime = DateTime.SpecifyKind(s.StartTime, DateTimeKind.Utc), Duration = s.Duration, RoomNumber = s.RoomNumber, Speaker = s.Speaker }).ToList(); var scheduleEvent = new ScheduleEvent { EventDefinitionId = eventDefinition.EventDefinitionId, Rooms = eventDefinition.RoomNumber, Sessions = scheduleSessions }; var viewModel = new ScheduleViewModel { EventDefinition = scheduleEvent, Times = times }; return viewModel; }
public void RegeneratePaymentSchedule(bool hasValidationError) { PaymentSchedule = new ScheduleViewModel { HasValidationError = hasValidationError }; }
public ActionResult Edit(ScheduleViewModel schedule) { #region validation if (schedule == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Invalid schedule"); } if (schedule.HomeTeam == null || schedule.AwayTeam == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Invalid schedule teams"); } if (schedule.HomeTeam.Id == schedule.AwayTeam.Id) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Home and away teams cannot be the same"); } // load the teams from the Db schedule.AwayTeam = TeamViewModel.Get(schedule.AwayTeam.Id); schedule.HomeTeam = TeamViewModel.Get(schedule.HomeTeam.Id); // re-validate teams if (schedule.HomeTeam == null || schedule.AwayTeam == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Invalid schedule teams"); } #endregion schedule.Save(); return RedirectToAction("Index"); }
public void Execute(object parameter) { var shell = IoC.Get<IShell>(); var context = IoC.Get<EnvironmentExplorerViewModel>().GetCurrentContext(); var viewModel = new ScheduleViewModel(new ScheduleModelProxy(new SMA.OneTimeSchedule(), context)); shell.OpenDocument(viewModel); }
public void TestNotifyPropertyChanged() { var vm = new ScheduleViewModel(); TestsHelper.TestPropertyWithNotifyPropertyChanged(vm, () => vm.Model); vm.Model = new ScheduleEditMock(); TestsHelper.TestPropertyWithNotifyPropertyChanged(vm, () => vm.StartImmediately); TestsHelper.TestPropertyWithNotifyPropertyChanged(vm, () => vm.NoEndDate); }
public ScheduleDeleteViewModel CreateViewModel(ScheduleDeleteOutputData outputData) { var scheduleViewModel = new ScheduleViewModel() { Id = outputData.Schedule.Id, DateTimeFrom = outputData.Schedule.DateTimeFrom.ToString("yyyy-MM-dd"), DateTimeTo = outputData.Schedule.DateTimeTo.ToString("yyyy-MM-dd"), Name = outputData.Schedule.Name }; return(new ScheduleDeleteViewModel() { ScheduleViewModel = scheduleViewModel }); }
public IActionResult Get(int id) { Schedule _schedule = _scheduleRepository .GetSingle(s => s.Id == id, s => s.Creator, s => s.Attendees); if (_schedule != null) { ScheduleViewModel _scheduleVM = Mapper.Map <Schedule, ScheduleViewModel>(_schedule); return(new OkObjectResult(_scheduleVM)); } else { return(NotFound()); } }
public void ShouldReturnBadRequestWhenAddFails() { var model = new ScheduleViewModel(); var entity = new Schedule(); validatorMock.Setup(x => x.IsValid(model)).Returns(true); mapperMock.Setup(x => x.Map <Schedule>(model)).Returns(entity); serviceMock.Setup(x => x.Add(entity, shipId)).Returns(false); var result = controller.Add(model, shipId); Assert.IsInstanceOf <BadRequestResult>(result); mapperMock.Verify(x => x.Map <Schedule>(model)); serviceMock.Verify(x => x.Add(entity, shipId), Times.Once()); }
public async Task <IHttpActionResult> Post([FromBody] ScheduleViewModel viewModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } viewModel.UserName = CurrentUserName; var newModel = Mapper.Map <ScheduleViewModel, Schedule>(viewModel); newModel.CreateUser = newModel.UpdateUser = User.Identity.Name; _scheduleRepository.Add(newModel); await UnitOfWork.SaveChangesAsync(); return(RedirectToRoute("", new { controller = "Schedule", id = newModel.Id })); }
public JsonResult AddSchedule(ScheduleViewModel schedule) { //db.Schedules.Add(schedule); //db.SaveChanges(); //var mysche = db.Schedules.Where(b => b.Day == schedule.Day).Where(c => c.Time == schedule.Time).FirstOrDefault().Id; //return Json(mysche, JsonRequestBehavior.AllowGet); var sched = Mapper.Map <ScheduleViewModel, Schedule> (schedule); scheduleService.CreateSchedule(sched); scheduleService.SaveSchedule(); var mysche = db.Schedules.Where(b => b.Day == schedule.Day).Where(c => c.Time == schedule.Time).FirstOrDefault().Id; return(Json(mysche, JsonRequestBehavior.AllowGet)); }
public async Task <IActionResult> Create(ScheduleViewModel ScheduleViewModel) { if (ModelState.IsValid) { var schedID = _context.BotSchedule.ToList().Count(); for (int j = 0; j < ScheduleViewModel.Respondents.Length; j++) { BotSchedule sched = new BotSchedule(); sched.Id = ScheduleViewModel.ID; sched.Date = ScheduleViewModel.StartDay; sched.Time = ScheduleViewModel.TimeOccur; sched.Monday = ScheduleViewModel.Monday.ToString().Substring(0, 1); sched.Tuesday = ScheduleViewModel.Tuesday.ToString().Substring(0, 1); sched.Wednesday = ScheduleViewModel.Monday.ToString().Substring(0, 1); sched.Thursday = ScheduleViewModel.Thursday.ToString().Substring(0, 1); sched.Friday = ScheduleViewModel.Friday.ToString().Substring(0, 1); sched.Saturday = ScheduleViewModel.Saturday.ToString().Substring(0, 1); sched.Sunday = ScheduleViewModel.Sunday.ToString().Substring(0, 1); sched.Creator = "Chris"; sched.ScheduleId = schedID; sched.Frequency = ScheduleViewModel.FrequencyOccur; sched.WelcomeMsg = ScheduleViewModel.WelcomeMsg; sched.Respondents = ScheduleViewModel.Respondents[j]; _context.Add(sched); await _context.SaveChangesAsync(); } for (int i = 0; i < ScheduleViewModel.Question.Length; i++) { BotQuestions quest = new BotQuestions(); quest.ScheduleId = schedID; quest.Questions = ScheduleViewModel.Question[i]; _context.Add(quest); await _context.SaveChangesAsync(); } //var SurveyId = _context.BotSchedule.ToList().LastOrDefault(); return(RedirectToAction(nameof(Scheduling))); } return(View(ScheduleViewModel)); }
public ScheduleViewModel GetSchedule(int tournamentId) { var games = _gameService.GetTournamentGames(tournamentId) .Where(g => g.GameDate.HasValue) .Select(GameViewModel.Map); var tournament = _tournamentService.GetTournamentScheduleInfo(tournamentId); var resultGroupedByWeek = games.GroupBy(GetWeekOfYear) .OrderBy(w => w.Key.Year) .ThenBy(w => w.Key.Week) .Select(w => new Tuple <int, List <GameViewModel> >(w.Key.Week, w.ToList())) .ToList(); var result = new ScheduleViewModel { Schedule = resultGroupedByWeek.Select(it => new WeekViewModel { Days = it.Item2 .GroupBy(item => item.Date.DayOfWeek) .Select(element => new ScheduleDayViewModel { Date = element.Select(d => d.Date).First(), Divisions = element.Select(data => new DivisionTitleViewModel { Id = data.DivisionId, Name = data.DivisionName, Rounds = element.Where(g => g.DivisionId == data.DivisionId) .Select(item => item.Round) .Distinct() .OrderBy(i => i) .Select(r => GetRoundName(r, tournament)) .ToList() }). Distinct(new DivisionTitleComparer()).ToList(), Games = element.OrderBy(g => g.AwayTeamName == null) .ThenBy(g => g.Date) .ToList() }).OrderBy(item => item.Date).ToList() } ).ToList() }; if (tournament.Scheme == TournamentSchemeEnum.PlayOff) { ClearDivisionNames(result); } return(result); }
// GET: ScheduleOnces/Edit/5 public PartialViewResult Edit(int?id) { if (id == null) { return(PartialView()); } Schedule schedule = _repo.FindBy(id); ScheduleViewModel vmodel = new ScheduleViewModel(); vmodel.Name = schedule.Name; vmodel.Repeats = schedule.Repeats; vmodel.StartDate = schedule.StartDate; if (schedule == null) { return(PartialView()); } if (schedule.GetType().BaseType.FullName == typeof(ScheduleOnce).FullName) { vmodel.Time = ((ScheduleOnce)schedule).Time; } if (schedule.GetType().BaseType.FullName == typeof(ScheduleDaily).FullName) { vmodel.RepeatOn = ((ScheduleDaily)schedule).RepeatOn; vmodel.StopDate = ((ScheduleDaily)schedule).StopDate; vmodel.Time = ((ScheduleDaily)schedule).Time; } if (schedule.GetType().BaseType.FullName == typeof(ScheduleWeekly).FullName) { vmodel.RepeatOnWeeks = ((ScheduleWeekly)schedule).RepeatOnWeeks; vmodel.RepeatOnDaysWeeks = ((ScheduleWeekly)schedule).RepeatOnDaysWeeks; vmodel.Time = ((ScheduleWeekly)schedule).Time; } if (schedule.GetType().BaseType.FullName == typeof(ScheduleMonthly).FullName) { vmodel.RepeatOnDay = ((ScheduleMonthly)schedule).RepeatOnDay; vmodel.RepeatOnMonth = ((ScheduleMonthly)schedule).RepeatOnMonth; vmodel.Time = ((ScheduleMonthly)schedule).Time; } if (schedule.GetType().BaseType.FullName == typeof(ScheduleMonthlyRelative).FullName) { vmodel.RepeatOnFirst = ((ScheduleMonthlyRelative)schedule).RepeatOnFirst; vmodel.RepeatOnDay2 = ((ScheduleMonthlyRelative)schedule).RepeatOnDay; vmodel.RepeatOnMonth2 = ((ScheduleMonthlyRelative)schedule).RepeatOnMonth; vmodel.Time = ((ScheduleMonthlyRelative)schedule).Time; } return(PartialView(vmodel)); }
public ExportSchedulePopupViewModel(BaseViewModel parent, ScheduleViewModel scheduleViewModel) : base(parent) { _scheduleViewModel = scheduleViewModel; Element = CreateView(); ShareItems = new ShareItem[] { // TODO: Localize strings new ShareItem() { Title = LocalizedResources.GetString("String_ScheduleExportToImage_Clipboard_Title"), Subtitle = LocalizedResources.GetString("String_ScheduleExportToImage_Clipboard_Subtitle"), ClickAction = ExportToClipboard }, new ShareItem() { Title = LocalizedResources.GetString("String_ScheduleExportToImage_Save_Title"), Subtitle = LocalizedResources.GetString("String_ScheduleExportToImage_Save_Subtitle"), ClickAction = ExportToFile }, // Only include share if it's supported App.IsSharingSupported ? new ShareItem() { Title = LocalizedResources.GetString("String_ScheduleExportToImage_Share_Title"), Subtitle = LocalizedResources.GetString("String_ScheduleExportToImage_Share_Subtitle"), ClickAction = ExportToShare } : null, // Cutting since implementing this is more complicated than expected. // See description below for more details. //new ShareItem() //{ // Title = "Send to printer", // Subtitle = "Print an image of your schedule", // ClickAction = ExportToPrinter //}, new ShareItem() { Title = LocalizedResources.GetString("String_ScheduleExportToImage_Cancel_Title"), Subtitle = LocalizedResources.GetString("String_ScheduleExportToImage_Cancel_Subtitle"), ClickAction = delegate { base.GoBack(); } } }.Where(i => i != null).ToArray(); }
public ActionResult ScheduleDepo(ScheduleViewModel model, HttpPostedFileBase file) { if (ModelState.IsValid) { try { var schedule = new Schedule() { AttorneyName = model.AttorneyName, //0 PhoneNumber = model.PhoneNumber, //1 ContactName = model.ContactName, //2 Email = model.Email, //3 DepoDateTime = model.DepoDateTime, //4 PlaceofTrial = model.PlaceofTrial, //5 Address = model.Address, //6 City = model.City, //7 State = model.StateValue, //8 Video = model.Video, //9 EstimatedTime = model.EstimatedTimeValue, //10 TurnaroundTime = model.TurnaroundTimeValue, //11 DeliveryComments = model.DeliveryComments //12 }; if (file != null) { schedule.FileAttachment = new FileAttachment() { FileStream = file.InputStream, FileName = file.FileName, ContentLength = file.ContentLength }; } MailManager.SendMail(schedule); } catch { model.SystemMessage.Message = @"There was a problem scheduling your depo. Please try again."; model.SystemMessage.MessageType = SystemMessageType.Error; return(View(model)); } } model = new ScheduleViewModel(); model.SystemMessage.Message = @"Your request to schedule a deposition has been sent."; model.SystemMessage.MessageType = SystemMessageType.Information; return(View(model)); }
public void ShouldReturnBadRequestAndValidationErrorsWhenModelIsNotValid() { var model = new ScheduleViewModel(); validatorMock.Setup(x => x.IsValid(model)).Returns(false); var errorsList = new List <string>(); validatorMock.SetupGet(x => x.ErrorList).Returns(errorsList); var result = controller.Add(model, shipId); Assert.IsInstanceOf <BadRequestObjectResult>(result); var badReqest = result as BadRequestObjectResult; Assert.AreEqual(errorsList, badReqest.Value); }
public async Task <ScheduleViewModel> GetAll() { try { var appointments = await _scheduleRepository.ListAllAsync(); var appointmentViewModelList = _mapper.Map <List <Appointment>, List <AppointmentViewModel> >(appointments); var scheduleViewModel = new ScheduleViewModel(); scheduleViewModel.AppointmentViewModelList = appointmentViewModelList; return(scheduleViewModel); } catch (Exception ex) { Console.WriteLine(ex); throw (ex); } }
public ActionResult EditSchedule(ScheduleViewModel model) { if (ModelState.IsValid) { var schedule = _doctorService.GetScheduleById(model.Id); // Can put validation if schedule is found or not schedule = Mapper.Map(model, schedule); var isUpdate = _doctorService.UpdateSchedule(schedule); if (isUpdate > 0) { return(RedirectToAction("Schedules")); } } return(View(model)); }
public IActionResult ChangeWeek(ScheduleViewModel schedule, string weekSelector) { switch (weekSelector) { case "Previous week": schedule.WeekNumber -= 1; break; case "Next week": schedule.WeekNumber += 1; break; } return(RedirectToAction("Schedule", ReturnBasicParameters(schedule.LaundryRoomId, schedule.WeekNumber))); }
/// <summary> /// Finds out whether two standings entries objects have the same properties. /// </summary> /// <param name="expected">The first object to compare.</param> /// <param name="actual">The second object to compare.</param> public static void AssertAreEqual(ScheduleViewModel expected, ScheduleViewModel actual) { if (expected == null && actual == null) { return; } Assert.False(expected == null || actual == null, "Instance should not be null."); actual.Schedule.Count.Should().Be(expected.Schedule.Count, $"Number of Week entries does not match."); for (var i = 0; i < expected.Schedule.Count; i++) { WeekViewModelComparer.AssertAreEqual(expected.Schedule[i], actual.Schedule[i], $"[Week#{i}]"); } }
private bool EditScheduleOnce(ScheduleViewModel vmodel, Schedule model) { if (model.GetType().BaseType.FullName != typeof(ScheduleOnce).FullName) { ScheduleOnce model1 = new ScheduleOnce(vmodel.Name, vmodel.Repeats, vmodel.StartDate, vmodel.Time); IEnumerable <SubscriptionModel> subscriptions = model.Subscriptions; AddReportFilters(subscriptions, model1, model.UserId, model.ID); return(false); } else { ((ScheduleOnce)model).Time = vmodel.Time; } return(true); }
public IActionResult AddEditSchedule(ScheduleViewModel model) { var existSchdule = _unitOfWork.Schedule.GetSchedulesById(model.Schedule.ID) == null ? false: true; if (!existSchdule) { _unitOfWork.Schedule.AddSchedule(model.Schedule); _unitOfWork.Complete(); return(RedirectToAction("ListSchedules")); } else { return(RedirectToAction("ListSchedules")); } }
/// <summary> /// Initializes a new instance of the <see cref="ScheduleViewModelBuilder"/> class /// </summary> public ScheduleViewModelBuilder() { _scheduleViewModel = new ScheduleViewModel() { TournamentId = 1, TournamentName = "Name", TournamentScheme = TournamentSchemeEnum.One, MaxNumberOfRounds = 3, Rounds = new GameServiceTestFixture().TestGameResults() .Build().GroupBy(d => d.Round) .ToDictionary( d => d.Key, c => c.OrderBy(t => t.GameDate) .Select(x => GameResultViewModel.Map(x)).ToList()) }; }
public async Task <ActionResult> Index(string id, string dataSetId) { ScheduleViewModel scheduleViewModel = new ScheduleViewModel(); await scheduleViewModel.GenerateScheduleView(Session, id, dataSetId); ViewBag.dataSetId = dataSetId; ViewBag.dataSetIndexId = id; if (scheduleViewModel.errorOccurred) { return(RedirectToAction("Index", "Authenticate")); } else { return(View(scheduleViewModel)); } }
public async Task <IActionResult> GetById(int id) { var currentUserId = GetCurrentUserId(); var userSchedules = from schedule in dbContext.Schedules where schedule.UserId == currentUserId select schedule; var userSchedule = await userSchedules .Include(s => s.Timetable) .Include(s => s.Timetable.Location) .Include(s => s.Timetable.Course) .SingleAsync(s => s.Id == id); return(new ObjectResult(ScheduleViewModel.Map(userSchedule))); }
ScheduleViewModel GetClassAlterMutation(ScheduleViewModel schedule, int index) { var r = new Random(); var newSchedules = _classRepository.Create(); var newClasses = newSchedules[index].ClassFits; for (int i = 0; i < schedule.ClassFits.Count; i++) { if (0.1 > r.NextDouble()) { schedule.ClassFits[i] = newClasses[i]; } } return(schedule); }
public ActionResult AddSchedule(ScheduleViewModel model) { if (!ModelState.IsValid) { var schedule = new ScheduleViewModel { Schedule = model.Schedule, Doctors = db.Doctors.ToList() }; return(View(schedule)); } db.Schedules.Add(model.Schedule); db.SaveChanges(); return(RedirectToAction("ListOfSchedules")); }
public ActionResult BookNow(HireViewModel hrv) { // Session.Add("hireid", Request.QueryString["id"].ToString()); hrv.ScheduleId = Convert.ToInt32(Session["scheduleid"].ToString()); hrv.Tutorid = Convert.ToInt32(Session["teacherid"].ToString()); hrv.StudentId = Convert.ToInt32(Session["studentid"].ToString()); hrdb.InsertHire(hrv); ScheduleViewModel svm = new ScheduleViewModel(); svm.ScheduleId = Convert.ToInt32(Session["scheduleid"].ToString()); svm.Status = "Closed"; sdb.UpdateScheduleStatus(svm); ViewBag.Message = "Teacher Booked Successfully"; return(View()); }
public IActionResult Post([FromBody] ScheduleViewModel scheduleVM) { if (ModelState.IsValid) { var saveSchedule = Mapper.Map <Schedule>(scheduleVM); _scheduleRepository.AddSchedule(saveSchedule); if (!_scheduleRepository.Save()) { return(StatusCode(500, "A problem happened while handling yout request!")); } return(CreatedAtRoute("schedules", new { saveSchedule.Id }, saveSchedule)); } return(BadRequest(ModelState)); }
public async Task <IActionResult> AddShift(ScheduleViewModel scheduleViewModel) { if (scheduleViewModel.ScheduleId != 0) {//Edit if (ModelState.IsValid) { Schedule schedule = ConvertViewModeltoSchedule(scheduleViewModel); scheduleViewModel.DisplayEdit = false; try { _context.Update(schedule); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { scheduleViewModel.ScheduleId = 0; if (!ScheduleExists(schedule.ScheduleId)) { return(NotFound()); } else { throw; } } } } else {//Add if (ModelState.IsValid) { Schedule schedule = ConvertViewModeltoSchedule(scheduleViewModel); _context.Add(schedule); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } else { scheduleViewModel.Error = "Schedule could not be added"; } } scheduleViewModel = Load(scheduleViewModel); return(View("Index", scheduleViewModel)); }
public async Task <IActionResult> Remove([FromBody] ScheduleViewModel <MyAgendaViewModel> payload) { if (payload.key != null) { var result = _functionalService.Delete <MyAgenda>(Convert.ToInt32(payload.key)); } ApplicationUser appUser = await _userManager.GetUserAsync(User); List <MyAgenda> books = new List <MyAgenda>(); if (appUser != null) { books = _functionalService.GetList <MyAgenda>() .Where(x => x.CreateBy.Equals(appUser.Id)).ToList(); } return(Ok(books)); }
private List <object> BuildCalendarObjects(ScheduleViewModel scheduleViewModel) { var calendarObjects = new List <object> { new { id = scheduleViewModel.ID, title = scheduleViewModel.Title, start = scheduleViewModel.StartDate + scheduleViewModel.StartTime, end = scheduleViewModel.StartDate + scheduleViewModel.EndTime, url = Url.Action("ScheduleOccurrence", "Example", new { id = scheduleViewModel.ID, occurrenceDate = scheduleViewModel.StartDate }), allDay = false } }; return(calendarObjects); }
public async Task <ActionResult> PutScheduleAsync([FromBody] ScheduleViewModel model) { try { if (!ModelState.IsValid) { return(BadRequest()); } await _logic.PutAsync(model); return(Ok(model)); } catch (Exception e) { return(StatusCode(500, e)); } }
ScheduleViewModel CrossoverSchedule(ScheduleViewModel schedule1, ScheduleViewModel schedule2) { var crossSchedule = _classRepository.Create()[0]; for (int i = 0; i < crossSchedule.ClassFits.Count; i++) { if (new Random().NextDouble() > 0.5) { crossSchedule.ClassFits[i] = schedule1.ClassFits[i]; } else { crossSchedule.ClassFits[i] = schedule2.ClassFits[i]; } } return(crossSchedule); }
public async Task <IHttpActionResult> Put(int id, [FromBody] ScheduleViewModel viewModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } viewModel.UpdateUser = User.Identity.Name; viewModel.UpdateTime = Now; viewModel.LastAction = "更新"; var model = Mapper.Map <ScheduleViewModel, Schedule>(viewModel); _scheduleRepository.AttachAsModified(model); await UnitOfWork.SaveChangesAsync(); return(Ok(viewModel)); }
private static void CreateScheduleViewModel() { if (_scheduleViewModel == null) { _scheduleViewModel = new ScheduleViewModel(); } }
private static void ClearScheduleViewModel() { _scheduleViewModel.Cleanup(); _scheduleViewModel = null; }
public void OnSaved_Test() { var vm = new ScheduleViewModel(); var model = new ScheduleEditMock(); vm.Initialize(model); model = new ScheduleEditMock(); vm.OnSaved(model); Assert.AreSame(model, vm.Model); }
public void Initialize_Test() { var vm = new ScheduleViewModel(); Assert.IsNull(vm.Model); var model = new ScheduleEditMock(); vm.Initialize(model); Assert.AreSame(model, vm.Model); }
public ActionResult Edit(int id, ScheduleViewModel model) { try { if (ModelState.IsValid) { var schedule = scheduleService.GetById(id); schedule = ScheduleViewModel.ToModel(model, schedule); scheduleService.SaveSchedule(schedule); return RedirectToAction("Admin"); } } catch (Exception ex) { ModelState.AddModelError("", ex); this.LogError(ex); } ViewBag.PageTitle = "Edit Member"; ViewBag.Title = "Edit Member"; return View("CreateEdit", model); }