예제 #1
0
 public void Modify(Report report, AdditionalLocationViewModel viewModel)
 {
     if (report.Location == null)
     {
         report.Location = new Location();
     }
     report.Location.Description = viewModel.AdditionalLocation;
 }
예제 #2
0
 public void Modify(Report report, LocationViewModel viewModel)
 {
     if (report.Location == null)
     {
         report.Location = new Location();
     }
     report.Location.Building = viewModel.Building;
 }
예제 #3
0
 public void Modify(Report report, WeaponViewModel viewModel)
 {
     report.WeaponType = viewModel.Type;
     if (viewModel.Type == "Anders")
     {
         report.WeaponType = viewModel.OtherType;
     }
     report.WeaponLocation = viewModel.Location;
     report.Description = viewModel.Description;
 }
예제 #4
0
 public void Create(Report report, EditDoneViewModel viewModel)
 {
     viewModel.Category = report.Category;
     viewModel.Description = report.Description;
     viewModel.DrugsAction = report.DrugsAction;
     viewModel.FighterCount = report.FighterCount;
     viewModel.IsUnconscious = report.IsUnconscious;
     viewModel.DateOfTheft = report.DateOfTheft;
     viewModel.StolenObject = report.StolenObject;
     viewModel.Victim = report.Victim;
     viewModel.VictimName = report.VictimName;
     viewModel.IsWeaponPresent = report.IsWeaponPresent;
     viewModel.WeaponLocation = report.WeaponLocation;
     viewModel.WeaponType = report.WeaponType;
     viewModel.Location = report.Location;
     viewModel.Perpetrator = report.Perpetrator;
     viewModel.Vehicle = report.Vehicle;
     viewModel.Contact = report.Contact;
 }
예제 #5
0
        public void Modify(Report report, EditDoneViewModel 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;
            if(viewModel.WeaponType == "Anders")
            {
                report.WeaponType = viewModel.OtherType;
            }
            report.Location = viewModel.Location;
            report.Perpetrator = viewModel.Perpetrator;
            report.Vehicle = viewModel.Vehicle;

            if (viewModel.Contact.Name != null || viewModel.Contact.PhoneNumber != null || viewModel.Contact.EmailAddress != null)
            {
                if (report.Contact == null)
                {
                    report.Contact = new Contact();
                }
                report.Contact = viewModel.Contact;
            }
            else
            {
                report.Contact = null;
            }
        }
예제 #6
0
 public void Modify(Report report, VehicleViewModel viewModel)
 {
     report.Vehicle = new Vehicle
     {
         Brand = viewModel.Brand,
         Color = viewModel.Color,
         NumberPlate = viewModel.NumberPlate,
         AdditionalFeatures = viewModel.AdditionalFeatures,
         VehicleType = viewModel.VehicleType
     };
 }
예제 #7
0
 public void Modify(Report report, StatusChangeViewModel viewModel)
 {
     report.Status = viewModel.Status;
     report.IsVisible = viewModel.IsVisible;
 }
예제 #8
0
        public async Task<ActionResult> Fight(FightViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return View(viewModel);
            }

            var report = new Report();

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

            // TODO: add error handling

            if (report.IsWeaponPresent ?? false)
            {
                return RedirectToAction("Weapons");
            }

            return RedirectToAction("Contact");
        }
예제 #9
0
 public void Modify(Report report, NuisanceViewModel viewModel)
 {
     report.Description = viewModel.Description;
 }
예제 #10
0
 public void Modify(Report report, FightViewModel viewModel)
 {
     report.FighterCount = viewModel.FighterCount;
     report.IsWeaponPresent = viewModel.IsWeaponPresent;
     report.Description = viewModel.Description;
 }
예제 #11
0
        public async Task<ActionResult> Perpetrator(PerpetratorViewModel viewModel, bool? hasVictim)
        {
            var victim = hasVictim.HasValue && hasVictim.Value;

            if (!ModelState.IsValid)
            {
                return View(viewModel);
            }
            var report = new Report();
            _modelFactory.Modify(report, viewModel);
            await _reportProxy.PatchAsync(GetCurrentReportId(), report);

            return RedirectToAction(victim ? "Victim" : "Vehicle");
        }
예제 #12
0
        public async Task<ActionResult> Weapons(WeaponViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return View(viewModel);
            }

            var report = new Report();

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

            if (report.Category == "Fight")
            {
                return RedirectToAction("Contact");
            }

            return RedirectToAction("Perpetrator");
        }
예제 #13
0
        private async Task EnsureReportAccess(Report report)
        {
            var loginProxy = new AuthenticationProxy(WebConfigurationManager.AppSettings["WebApiUrl"], "/api/oauth");
            var token = await loginProxy.LoginAnonymous(report.AnonymousToken);

            // TODO: add error handling
            var authCookie = new HttpCookie("token", token.Value)
            {
                Expires = DateTime.Now.AddMinutes(token.ExpiresIn)
            };
            var cookie = new HttpCookie("report", report.Id.ToString());

            Response.Cookies.Add(cookie);
            Response.Cookies.Add(authCookie);
        }
예제 #14
0
        public async Task<ActionResult> ContactRequired(ContactRequiredViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return View(viewModel);
            }

            var report = new Report();
            _modelFactory.Modify(report, viewModel);
            await _reportProxy.PatchAsync(GetCurrentReportId(), report);

            return RedirectToAction("Done");
        }
예제 #15
0
        public async Task<ActionResult> Contact(ContactViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return View(viewModel);
            }

            if (viewModel.EmailAddress != null || viewModel.Name != null || viewModel.PhoneNumber != null)
            {
                var report = new Report();
                _modelFactory.Modify(report, viewModel);
                await _reportProxy.PatchAsync(GetCurrentReportId(), report);
            }

            return RedirectToAction("Done");
        }
예제 #16
0
        public async Task<ActionResult> Vehicle(VehicleViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return View(viewModel);
            }

            var report = new Report();

            if (viewModel.HasVehicle)
            {
                _modelFactory.Modify(report, viewModel);
                report = await _reportProxy.PatchAsync(GetCurrentReportId(), report);
            }
            else
            {
                report = await GetCurrentReport();
            }

            switch (report.Category)
            {
                case "Theft":
                case "Nuisance":
                case "Other":
                    return RedirectToAction("ContactRequired");

                default:
                    return RedirectToAction("Contact");
            }
        }
예제 #17
0
        public async Task<ActionResult> Victim(VictimViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return View(viewModel);
            }

            var report = new Report();
            _modelFactory.Modify(report, viewModel);
            await _reportProxy.PatchAsync(GetCurrentReportId(), report);

            // TODO: add error handling
            return RedirectToAction("Vehicle");
        }
예제 #18
0
 public void Modify(Report report, TheftViewModel viewModel)
 {
     report.StolenObject = viewModel.StolenObject ;
     report.DateOfTheft = viewModel.DateOfTheft.Add(viewModel.TimeOfTheft.TimeOfDay);
     report.Description = viewModel.Description;
 }
예제 #19
0
        public async Task<ActionResult> Location(LocationViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return View(viewModel);
            }

            var reportId = GetCurrentReportId();
            var report = new Report();

            _modelFactory.Modify(report, viewModel);
            var responseReport = await _reportProxy.PatchAsync(reportId, report);

            return RedirectToAction("AdditionalLocation");
        }
예제 #20
0
        public async Task<ActionResult> Bullying(BullyingViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return View(viewModel);
            }

            var report = new Report();
            _modelFactory.Modify(report, viewModel);
            report = await _reportProxy.PatchAsync(GetCurrentReportId(), report);

            if (viewModel.HasPerpetrator && !viewModel.HasVictim)
            {
                return RedirectToAction("Perpetrator");
            }
            else if (!viewModel.HasPerpetrator && viewModel.HasVictim)
            {
                return RedirectToAction("Victim");
            }
            else if (viewModel.HasPerpetrator && viewModel.HasVictim)
            {
                return RedirectToAction("Perpetrator", routeValues: new { hasVictim = viewModel.HasVictim });
            }

            return RedirectToAction("Vehicle");
        }
예제 #21
0
 public void Modify(Report report, FirstAidViewModel viewModel)
 {
     report.IsUnconscious = viewModel.IsUnconscious == "Ja";
 }
예제 #22
0
 public void Modify(Report report, VictimViewModel viewModel)
 {
     report.Victim = viewModel.Victim;
 }
예제 #23
0
 public void Modify(Report report, DrugsViewModel viewModel)
 {
     report.DrugsAction = viewModel.Action;
     report.Description = viewModel.Description;
 }
예제 #24
0
 public void Modify(Report report, OtherViewModel viewModel)
 {
     report.Description = viewModel.Description;
 }
예제 #25
0
 public void Modify(Report report, PerpetratorViewModel viewModel)
 {
     if (report.Perpetrator == null)
     {
         report.Perpetrator = new Perpetrator();
     }
     if (viewModel.AgeRange != null)
     {
         var values = viewModel.AgeRange.Split('-');
         var minimumAge = Convert.ToInt32(values[0]);
         var maximumAge = Convert.ToInt32(values[1]);
         report.Perpetrator.MinimumAge = minimumAge;
         report.Perpetrator.MaximumAge = maximumAge;
     }
     report.Perpetrator.Name = viewModel.Name;
     report.Perpetrator.Clothing = viewModel.Clothing;
     report.Perpetrator.Sex = viewModel.Sex;
     report.Perpetrator.SkinColor = viewModel.SkinColor;
     report.Perpetrator.UniqueProperties = viewModel.UniqueProperties;
 }
예제 #26
0
 public void Modify(Report report, ContactRequiredViewModel viewModel)
 {
     if (report.Contact == null)
     {
         report.Contact = new Contact();
     }
     report.Contact.Name = viewModel.Name;
     report.Contact.PhoneNumber = viewModel.PhoneNumber;
     report.Contact.EmailAddress = viewModel.EmailAddress;
 }
예제 #27
0
 public void Modify(Report report, BullyingViewModel viewModel)
 {
     report.Description = viewModel.Description;
     report.VictimName = viewModel.VictimName;
 }
예제 #28
0
        public async Task<ActionResult> Drugs(DrugsViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return View(viewModel);
            }

            var report = new Report();

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

            return RedirectToAction("Perpetrator");
        }