public ActionResult Get(int? id) { var model = new ClientModel(); if (id > 0) { model = ClientRepository.Select(x => x.ID == id).FirstOrDefault().ToModel(); } var judete = JudetRepository.Select(); ViewBag.Judete = Utils.SelectList(judete, "ID", "Nume", "Selectati Judetul"); return PartialView("_Edit", model); }
public ActionResult Save(ClientModel model) { if (ModelState.IsValid) { var entity = ClientRepository.Select(x => x.ID == model.Id).FirstOrDefault() ?? new Client(); model.ToEntity(ref entity); ClientRepository.Insert(entity); return Json(new { success = true }); } var judete = JudetRepository.Select(); ViewBag.Judete = Utils.SelectList(judete, "ID", "Nume", "Selectati Judetul"); return PartialView("_Edit", model); }