Пример #1
0
        public ViewResult Details(int id)
        {
            Squawk squawk = _dataService.GetSquawkById(id);

            SquawkDetailViewModel model = new SquawkDetailViewModel() 
            { 
                AircraftId = squawk.AircraftId,
                Description = squawk.Description,
                Id = squawk.Id,
                PostedBy = squawk.PostedBy.FullName,
                PostedOn = squawk.PostedOn,
                RegistrationNumber = squawk.Aircraft.RegistrationNumber,
                ResolvedOn = squawk.ResolvedOn,
                ResolutionNotes = squawk.ResolutionNotes,
                Status = squawk.Status,
                Subject = squawk.Subject
            };

            if (squawk.ResolvedById != null)
            {
                Member resolvedBy = _dataService.GetMember((int)squawk.ResolvedById);
                model.ResolvedBy = resolvedBy.FullName;
            }

            foreach (var comment in squawk.Comments)
            {
                SquawkCommentViewModel commentVM = new SquawkCommentViewModel()
                {
                    Id = comment.Id,
                    PostedById = comment.PostedByMemberId,
                    PostedOn = comment.PostDate,
                    Text = comment.Text
                };

                Member poster = _dataService.GetMember(comment.PostedByMemberId);
                commentVM.PostedBy = poster.FullName;

                model.Comments.Add(commentVM);
            }

            return View(ViewNames.SquawkDetails, model);
        }
Пример #2
0
        public ActionResult ResolveSquawk(ResolveSquawkViewModel viewModel)
        {
            ProfileCommon profile = (ProfileCommon)HttpContext.Profile;
            Squawk squawk = _dataService.GetSquawkById(viewModel.Id);
            squawk.ResolutionNotes = viewModel.ResolutionNotes;
            squawk.ResolvedById = profile.MemberId;
            squawk.ResolvedOn = DateTime.Now;
            squawk.Status = viewModel.Status;

            _dataService.UpdateSquawk(squawk);

            SquawkDetailViewModel sqVM = new SquawkDetailViewModel()
            {
                Id = squawk.Id,
                AircraftId = squawk.AircraftId,
                Description = squawk.Description,
                PostedById = squawk.PostedById,
                PostedOn = squawk.PostedOn,
                RegistrationNumber = squawk.Aircraft.RegistrationNumber,
                ResolutionNotes = squawk.ResolutionNotes,
                ResolvedOn = squawk.ResolvedOn,
                ResolvedBy = profile.FirstName + " " + profile.LastName,
                Status = squawk.Status,
                Subject = squawk.Subject
            };

            return View(ViewNames.SquawkDetails, sqVM);
        }