Beispiel #1
0
        public async Task <IActionResult> Upsert(int?id)
        {
            IEnumerable <Marca> npList = await _npRepo.GetAllAsync(SD.MarcaAPIPath, HttpContext.Session.GetString("JWToken"));

            PatrimoniosVM objVM = new PatrimoniosVM()
            {
                MarcasList = npList.Select(i => new SelectListItem {
                    Text  = i.Nome,
                    Value = i.Id.ToString()
                }),
                Patrimonio = new Patrimonio()
            };

            if (id == null)
            {
                //Insert Or create
                return(View(objVM));
            }
            objVM.Patrimonio = await _npPatrimonio.GetAsync(SD.PatrimonioAPIPath, id.GetValueOrDefault(), HttpContext.Session.GetString("JWToken"));

            if (objVM.Patrimonio == null)
            {
                //Edit or Update
                return(NotFound());
            }
            return(View(objVM));
        }