Example #1
0
        public ActionResult Edit(EditSquawkViewModel viewModel)
        {

            if (ModelState.IsValid)
            {
                Squawk squawk = _dataService.GetSquawkById(viewModel.Id);
                squawk.Status = viewModel.Status;
                squawk.ResolutionNotes = viewModel.ResolutionNotes;
                squawk.Subject = viewModel.Subject;
                squawk.Description = viewModel.Description;

                _dataService.UpdateSquawk(squawk);

                return RedirectToAction("ListActiveSquawks");
            }

            //List<Aircraft> aircraftList = _dataService.GetAllAirplanes();
            //List<Member> memberList = _dataService.GetAllMembersByRole("Admin");
            //ViewBag.AircraftId = new SelectList(aircraftList, "Id", "Name", squawk.AircraftId);
            //ViewBag.OriginatorId = new SelectList(memberList, "Id", "Status", squawk.PostedById);

            return View(viewModel);
        }
Example #2
0
        public ActionResult Edit(int id)
        {
            Squawk squawk = _dataService.GetSquawkById(id);
            List<Aircraft> aircraftList = _dataService.GetAllAirplanes();
            List<Member> memberList = _dataService.GetAllMembersByRole("Admin");

            EditSquawkViewModel viewModel = new EditSquawkViewModel();
            viewModel.AircraftId = squawk.AircraftId;
            viewModel.Description = squawk.Description;
            viewModel.Id = squawk.Id;
            viewModel.PostedById = squawk.PostedById;
            viewModel.PostedBy = squawk.PostedBy.FullName;
            viewModel.PostedOn = squawk.PostedOn;
            viewModel.RegistrationNumber = squawk.Aircraft.RegistrationNumber;
            viewModel.Status = squawk.Status;
            viewModel.Subject = squawk.Subject;

            //TODO: Finish this!
            if (squawk.Comments.Count() > 0)
            {
                viewModel.Comments = squawk.Comments.Select(c => new SquawkCommentViewModel() { Text = c.Text }).ToList(); 
            }

            ViewBag.AircraftId = new SelectList(aircraftList, "Id", "Name", squawk.AircraftId);
            ViewBag.OriginatorId = new SelectList(memberList, "Id", "Status", squawk.PostedById);

            return View(viewModel);
        }