Exemplo n.º 1
0
        public async Task <IActionResult> AddPOI(AddPOIView modal, CancellationToken cancellationToken)
        {
            var type = await _mappingService.GetTypeByIdAsync(modal.TypeId);

            if (type == null)
            {
                modal.Message = "Cannot add POI. Please go back and try adding from the type again.";
                ModelState.AddModelError("", "Cannot add POI. Please go back and try adding from the type again.");
            }
            else
            {
                if (type.DepartmentId != DepartmentId)
                {
                    Unauthorized();
                }
            }

            if (ModelState.IsValid)
            {
                modal.Poi.PoiTypeId = modal.TypeId;
                await _mappingService.SavePOIAsync(modal.Poi, cancellationToken);

                return(RedirectToAction("POIs"));
            }

            return(View(modal));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> AddPOI(int poiTypeId)
        {
            var modal = new AddPOIView();

            modal.TypeId = poiTypeId;
            modal.Poi    = new Poi();


            return(View(modal));
        }