示例#1
0
 private SquadronLogListViewModel CreateSquadronLogListViewModel(Guid flightLogId, SquadronLogViewModel squadronLogViewModel)
 {
     var viewModel = new SquadronLogListViewModel();
     var flightLog = Repository.Get<FlightLog>(flightLogId);
     viewModel.FlightLog = Mapper.Map<FlightLog, FlightLogListItemViewModel>(flightLog);
     var squadronLogs = flightLog.SquadronLogs;
     viewModel.Items = Mapper.Map<IEnumerable<SquadronLog>, IEnumerable<SquadronLogViewModel>>(squadronLogs.ToList());
     viewModel.CurrentSquadronLog = squadronLogViewModel;
     if (squadronLogViewModel == null)
         viewModel.CurrentSquadronLog = new SquadronLogViewModel() { FlightLogId = flightLogId };
     viewModel.CurrentSquadronLog.SetAvailablePersons(Repository.GetAllActivePersons());
     return viewModel;
 }
示例#2
0
 private SquadronLogViewModel CreateSquadronLogViewModel(SquadronLog squadronLog)
 {
     var viewModel = new SquadronLogViewModel();
     if (squadronLog != null)
     {
         Mapper.Map<SquadronLog, SquadronLogViewModel>(squadronLog, viewModel);
     }
     viewModel.SetAvailablePersons(Repository.GetAllActivePersons());
     viewModel.IsFlightLogManager = CurrentUser.Roles.FlightLogManager;
     return viewModel;
 }
示例#3
0
 public virtual ActionResult BulkCreateSquadronLog(SquadronLogViewModel squadronLogViewModel)
 {
     this.Validate(squadronLogViewModel, string.Empty);
     if (!ModelState.IsValid)
     {
         var viewModel = CreateSquadronLogListViewModel(squadronLogViewModel.FlightLogId.Value, squadronLogViewModel);
         return View(Views.BulkCreateSquadronLog, viewModel);
     }
     var flightLog = Repository.Get<FlightLog>(squadronLogViewModel.FlightLogId.Value);
     var squadronLog = Mapper.Map<SquadronLogViewModel, SquadronLog>(squadronLogViewModel);
     squadronLog.Person = Repository.GetUserByUsername(squadronLogViewModel.PersonUsername).Person;
     flightLog.AddSquadronLog(squadronLog);
     return RedirectToAction(MVC.FlightLogs.BulkCreateSquadronLog(squadronLogViewModel.FlightLogId.Value));
 }
示例#4
0
 public virtual ActionResult EditSquadronLog(Guid id, SquadronLogViewModel squadronLogViewModel)
 {
     var squadronLog = Repository.Get<SquadronLog>(id);
     this.Validate(squadronLogViewModel, string.Empty);
     if (!ModelState.IsValid)
     {
         var viewModel = CreateSquadronLogViewModel(squadronLog);
         return View(viewModel);
     }
     Mapper.Map<SquadronLogViewModel, SquadronLog>(squadronLogViewModel, squadronLog);
     squadronLog.Person = Repository.GetUserByUsername(squadronLogViewModel.PersonUsername).Person;
     squadronLog.MarkedUpdated();
     return RedirectToAction(MVC.FlightLogs.EditFlightLog(squadronLogViewModel.FlightLogId.Value));
 }