public ActionResult MySettings(Taxpayer taxpayer) { if (ModelState.IsValid) { db.Entry(taxpayer).State = EntityState.Modified; try { db.SaveChanges(); } catch (Exception ex) { //TODO: Improve message ModelState.AddModelError(String.Empty, ex.Message); ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "Name", taxpayer.DepartmentId); ViewBag.DocumentTypeId = new SelectList(db.DocumentTypes, "DocumentTypeId", "Description", taxpayer.DocumentTypeId); ViewBag.MunicipalityId = new SelectList(db.Municipalities .Where(m => m.DepartmentId == db.Departments.FirstOrDefault().DepartmentId) .OrderBy(m => m.Name), "MunicipalityId", "Name", taxpayer.MunicipalityId); return(View(taxpayer)); } return(RedirectToAction("Index", "Home")); } ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "Name", taxpayer.DepartmentId); ViewBag.DocumentTypeId = new SelectList(db.DocumentTypes, "DocumentTypeId", "Description", taxpayer.DocumentTypeId); ViewBag.MunicipalityId = new SelectList(db.Municipalities .Where(m => m.DepartmentId == taxpayer.DepartmentId) .OrderBy(m => m.Name), "MunicipalityId", "Name", taxpayer.MunicipalityId); return(View(taxpayer)); }
public ActionResult Edit([Bind(Include = "DepartmentId,Name")] Department department) { if (ModelState.IsValid) { db.Entry(department).State = EntityState.Modified; try { db.SaveChanges(); } catch (Exception exception) { if (exception.InnerException != null && exception.InnerException.InnerException != null && exception.InnerException.InnerException.Message.Contains("Index")) { ModelState.AddModelError(string.Empty, "There are a record with the same descripction"); } else { ModelState.AddModelError(string.Empty, exception.Message); } return(View(department)); } return(RedirectToAction("Index")); } return(View(department)); }
public ActionResult Edit([Bind(Include = "PropertyTypeId,Description,Notes")] PropertyType propertyType) { if (ModelState.IsValid) { db.Entry(propertyType).State = EntityState.Modified; try { db.SaveChanges(); } catch (Exception ex) { if (ex.InnerException != null && ex.InnerException.InnerException != null && ex.InnerException.InnerException.Message.Contains("Index")) { ModelState.AddModelError(String.Empty, "The are a record with the same description"); } else { ModelState.AddModelError(String.Empty, ex.Message); } return(View(propertyType)); } return(RedirectToAction("Index")); } return(View(propertyType)); }
public ActionResult Edit([Bind(Include = "MunicipalityId,DepartmentId,Name")] Municipality municipality) { if (ModelState.IsValid) { db.Entry(municipality).State = EntityState.Modified; try { db.SaveChanges(); } catch (Exception ex) { if (ex.InnerException != null && ex.InnerException.InnerException != null && ex.InnerException.InnerException.Message.Contains("Index")) { ModelState.AddModelError(string.Empty, "Ya existe un registro con el mismo nombre"); } else { ModelState.AddModelError(string.Empty, ex.Message); } ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "Name", municipality.DepartmentId); return(View(municipality)); } return(RedirectToAction("Index")); } ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "Name", municipality.DepartmentId); return(View(municipality)); }
public ActionResult Edit([Bind(Include = "DocumentTypeId,Description")] DocumentType documentType) { if (ModelState.IsValid) { db.Entry(documentType).State = EntityState.Modified; try { db.SaveChanges(); } catch (Exception ex) { if (ex.InnerException != null && ex.InnerException.InnerException != null && ex.InnerException.InnerException.Message.Contains("Index")) { ModelState.AddModelError(string.Empty, "Ya existe un registro con el mismo nombre"); } else { ModelState.AddModelError(string.Empty, ex.Message); } return(View(documentType)); } return(RedirectToAction("Index")); } return(View(documentType)); }
public ActionResult Edit([Bind(Include = "DocumentTypeId,Description")] DocumentType documentType) { if (ModelState.IsValid) { db.Entry(documentType).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(documentType)); }
public ActionResult Edit([Bind(Include = "TaxId,Stratum,Rate")] Tax tax) { if (ModelState.IsValid) { db.Entry(tax).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tax)); }
public ActionResult Edit([Bind(Include = "MunicipalityId,DepartmentId,Name")] Municipality municipality) { if (ModelState.IsValid) { db.Entry(municipality).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "Name", municipality.DepartmentId); return(View(municipality)); }
public ActionResult EditMunicipality(Municipality view) { if (ModelState.IsValid) { db.Entry(view).State = EntityState.Modified; try { db.SaveChanges(); } catch (Exception ex) { ModelState.AddModelError(String.Empty, ex.Message); return(View(view)); } return(RedirectToAction(String.Format("Details/{0}", view.DepartmentId))); } return(View(view)); }
public ActionResult Edit([Bind(Include = "PropertyId,TaxPaerId,Phone,DepartmentId,MunicipalityId,Address,PropertyTypeId,Stratus,Area")] Property property) { if (ModelState.IsValid) { db.Entry(property).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "Name", property.DepartmentId); ViewBag.MunicipalityId = new SelectList(db.Municipalities, "MunicipalityId", "Name", property.MunicipalityId); ViewBag.PropertyTypeId = new SelectList(db.PropertyTypes, "PropertyTypeId", "Description", property.PropertyTypeId); ViewBag.TaxPaerId = new SelectList(db.TaxPaers, "TaxPaerId", "FirstName", property.TaxPaerId); return(View(property)); }
public ActionResult Edit([Bind(Include = "EmployeeId,FirstName,LastName,UserName,Phone,DepartmentId,MunicipalityId,Address,DocumentTypeId,Document,BossId")] Employee employee) { if (ModelState.IsValid) { db.Entry(employee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BossId = new SelectList(db.Employees, "EmployeeId", "FullName", employee.BossId); ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "Name", employee.DepartmentId); ViewBag.DocumentTypeId = new SelectList(db.DocumentTypes, "DocumentTypeId", "Description", employee.DocumentTypeId); ViewBag.MunicipalityId = new SelectList(db.Municipalities .Where(m => m.DepartmentId == db.Departments.FirstOrDefault().DepartmentId) .OrderBy(m => m.Name), "MunicipalityId", "Name"); return(View(employee)); }
public ActionResult Edit([Bind(Include = "TaxPaerId,FirsName,LastName,UserName,Phone,DepartmentId,MunicipalityId,Address,DocumentTypeId,Document")] TaxPaer taxPaer) { if (ModelState.IsValid) { db.Entry(taxPaer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "Name", taxPaer.DepartmentId); ViewBag.DocumentTypeId = new SelectList(db.DocumentTypes, "DocumentTypeId", "Description", taxPaer.DocumentTypeId); ViewBag.MunicipalityId = new SelectList(db.Municipalities .Where(m => m.DepartmentId == taxPaer.MunicipalityId).OrderBy(m => m.Name), "MunicipalityId", "Name", taxPaer.MunicipalityId); return(View(taxPaer)); }