Beispiel #1
0
        public void Modify(Report report, DoneViewModel viewModel)
        {
            report.Category        = viewModel.Category;
            report.Description     = viewModel.Description;
            report.DrugsAction     = viewModel.DrugsAction;
            report.FighterCount    = viewModel.FighterCount;
            report.IsUnconscious   = viewModel.IsUnconscious;
            report.DateOfTheft     = viewModel.DateOfTheft;
            report.StolenObject    = viewModel.StolenObject;
            report.Victim          = viewModel.Victim;
            report.VictimName      = viewModel.VictimName;
            report.IsWeaponPresent = viewModel.IsWeaponPresent;
            report.WeaponLocation  = viewModel.WeaponLocation;
            report.WeaponType      = viewModel.WeaponType == "Anders" ? viewModel.WeaponTypeOther : viewModel.WeaponType;
            report.Location        = viewModel.Location;
            report.Perpetrators    = viewModel.Perpetrators;
            report.Vehicles        = viewModel.Vehicles;

            if (viewModel.ContactName != null || viewModel.ContactPhoneNumber != null || viewModel.ContactEmail != null)
            {
                if (report.Contact == null)
                {
                    report.Contact = new Contact();
                }
                report.Contact.EmailAddress = viewModel.ContactEmail;
                report.Contact.PhoneNumber  = viewModel.ContactPhoneNumber;
                report.Contact.Name         = viewModel.ContactName;
            }
            else
            {
                report.Contact = null;
            }
        }
        public async Task <ActionResult> Done(DoneViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(new DoneViewModel(await GetCurrentReport())));
            }

            var report = new Report();

            _modelFactory.Modify(report, viewModel);
            await _reportProxy.PatchAsync(GetCurrentReportId(), report);

            TempData["Changed"] = true;

            return(RedirectToAction("Done"));
        }