public ActionResult SaveEdit(GradModel grad) { try { if (HttpContext.Session.GetObjectFromJson <KorisnikModel>("LogovaniKorisnik") == null) { return(View("~/Views/Login/Index.cshtml")); } grad.PostanskiBrojID = Convert.ToInt32(HttpContext.Session.GetInt32("GradID")); GradDAO.UpdateCity(grad); return(RedirectToAction(nameof(Index))); } catch (Exception e) { return(RedirectToAction(nameof(Edit))); } }
public IActionResult RowUpdate(int key, string values) { try { GradModel updatedCity = GradDAO.GetCityById(key); JsonConvert.PopulateObject(values, updatedCity); if (!TryValidateModel(updatedCity)) { return(BadRequest()); } GradDAO.UpdateCity(updatedCity); } catch (Exception) { } return(Ok()); }