Example #1
0
        public IActionResult StatusCodeView([FromQuery] int code)
        {
            var view = View(StatusCodeViewModel.Create(new ApiResponse(code)));

            view.StatusCode = code;
            return(view);
        }
        public IActionResult Delete(Guid id)
        {
            StatusCodeViewModel sCodeVm = new StatusCodeViewModel();

            using (StatusCodeDBContext db = new StatusCodeDBContext())
            {
                using (var dbB = new BridgeDBContext())
                {
                    BridgeViewModel bridgeVm = new BridgeViewModel();
                    bridgeVm.BridgeList = dbB.Bridges.ToList();
                    bridgeVm.NewBridge  = dbB.Bridges.Where(
                        sc => sc.StatusId == id).FirstOrDefault();
                    if (bridgeVm.NewBridge == null)
                    {
                        sCodeVm.NewStatusCode = new StatusCode();
                        //find id
                        sCodeVm.NewStatusCode.StatusCodeId =
                            Guid.Parse(RouteData.Values["id"].ToString());
                        db.Entry(sCodeVm.NewStatusCode).State = EntityState.Deleted;
                        db.SaveChanges();
                        TempData["ResultMessage"] = "Status Code deleted";
                    }
                    else
                    {
                        TempData["ResultMessage"] =
                            "This Status Code has dependencies, cannot delete!";
                    }
                }
            }
            return(RedirectToAction("Index"));
        }
Example #3
0
        public IActionResult Naselje([FromBody] NaseljeViewModel model)
        {
            StatusCodeViewModel status = _naseljaService.NewNaselje(model);

            return(StatusCode(status.StatusCode, new {
                code = status.StatusCode,
                status = status.StatusMessage
            }));
        }
Example #4
0
        public IActionResult DeleteNaselje(int id)
        {
            StatusCodeViewModel status = _naseljaService.DeleteNaselje(id);

            return(StatusCode(status.StatusCode, new
            {
                code = status.StatusCode,
                status = status.StatusMessage
            }));
        }
        public IActionResult Index(StatusCodeViewModel statusCodeVM)
        {
            using (var db = new StatusCodeDBContext())
            {
                db.StatusCodes.Add(statusCodeVM.NewStatusCode);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
        }
        // GET: /<controller>/
        public IActionResult Index()
        {
            StatusCodeViewModel statusCodeVM = new StatusCodeViewModel();

            using (var db = new StatusCodeDBContext())
            {
                statusCodeVM.StatusCodeList = db.StatusCodes.ToList();
                statusCodeVM.NewStatusCode  = new StatusCode();
            }

            return(View(statusCodeVM));
        }
Example #7
0
        public IActionResult StatusCodeHandler(HttpStatusCode statusCode)
        {
            var name          = Enum.GetName(typeof(HttpStatusCode), statusCode) ?? "Unrecognized";
            var value         = (int)statusCode;
            var codeViewModel = new StatusCodeViewModel
            {
                Name  = name,
                Value = value
            };

            return(View("StatusCode", codeViewModel));
        }
        //GET Filled in Form
        public IActionResult Edit(Guid id)
        {
            //a new instance of the view model
            StatusCodeViewModel sCodeVM = new StatusCodeViewModel();

            using (StatusCodeDBContext db = new StatusCodeDBContext())
            {
                //find id location in database
                sCodeVM.NewStatusCode = db.StatusCodes.Where(
                    e => e.StatusCodeId == id).SingleOrDefault();

                //return view model
                return(View(sCodeVM));
            }
        }
Example #9
0
        public new IActionResult StatusCode(int id)
        {
            var viewModel = new StatusCodeViewModel {
                StatusCode = id
            };

            switch (id)
            {
            case 401:
                viewModel.Titulo   = "Não autorizado";
                viewModel.Mensagem = "Você não está autenticado ou autorizado.";
                break;

            case 404:
                viewModel.Titulo   = "Não encontrado";
                viewModel.Mensagem = "O registro requisitado não foi encontrado.";
                break;

            case 501:
                viewModel.Titulo   = "Não implementado";
                viewModel.Mensagem = "O servidor ainda não suporta a funcionalidade solicitada.";
                break;

            case 502:
                viewModel.Titulo   = "Bad Gateway";
                viewModel.Mensagem = "Ocorreu um erro de comunicação com o servidor.";
                break;

            case 503:
                viewModel.Titulo   = "Serviço indisponível";
                viewModel.Mensagem = "O servidor está em manutenção.";
                break;

            case 504:
                viewModel.Titulo   = "Gateway Time-Out";
                viewModel.Mensagem = "O tempo de conexão expirou.";
                break;

            default:
                viewModel.Titulo   = "Código não cadastrado";
                viewModel.Mensagem = "O código do erro HTTP não está cadastrado no sistema.";
                break;
            }
            return(View(nameof(StatusCode), viewModel));
        }
 public IActionResult Edit(StatusCodeViewModel obj)
 {
     //check for valid model
     if (ModelState.IsValid)
     {
         using (StatusCodeDBContext db = new StatusCodeDBContext())
         {
             //object for view model
             StatusCode sc = obj.NewStatusCode;
             //retrieve primary key/id from route data
             sc.StatusCodeId = Guid.Parse(RouteData.Values["id"].ToString());
             //update record status
             db.Entry(sc).State = EntityState.Modified;
             db.SaveChanges();
         }
     }
     return(RedirectToAction("Index"));
 }
Example #11
0
        public IActionResult StatusCodeGet(int statusCode)
        {
            if (400 <= statusCode && statusCode < 600)
            {
                var model = new StatusCodeViewModel
                {
                    StatusCode   = statusCode,
                    ReasonPhrase = ReasonPhrases.GetReasonPhrase(statusCode)
                };

                HttpContext.Response.StatusCode = statusCode;
                return(View("StatusCode", model));
            }
            else
            {
                return(Redirect("/"));
            }
        }
        private static List <SelectListItem> GetStatusCodesDDL()
        {
            List <SelectListItem> sCode = new List <SelectListItem>();
            StatusCodeViewModel   scvm  = new StatusCodeViewModel();

            using (var db = new StatusCodeDBContext())
            {
                scvm.StatusCodeList = db.StatusCodes.ToList();
            }
            foreach (StatusCode s in scvm.StatusCodeList)
            {
                sCode.Add(new SelectListItem
                {
                    Text  = s.StatusName,
                    Value = s.StatusCodeId.ToString()
                });
            }
            return(sCode);
        }
Example #13
0
        public IActionResult StatusCodeHandler(int statusCode)
        {
            var statusCodeResult = HttpContext.Features.Get <IStatusCodeReExecuteFeature>();

            var viewModel = new StatusCodeViewModel
            {
                Code        = statusCode,
                Path        = statusCodeResult.OriginalPath,
                QueryString = statusCodeResult.OriginalQueryString,
            };

            _logger.LogWarning(viewModel.ToString());

            switch (statusCode)
            {
            case 404:
                viewModel.Message = "页面未找到";
                break;
            }

            return(View("StatusCode", viewModel));
        }