private void createEditButton_Click(object sender, EventArgs e) { if (_editMode) { if (_sectorService.EditIndustrialSector(_sector)) { int current = EasyCRMForm.getForm().sectorsBindingSource.Position; EasyCRMForm.getForm().sectorsBindingSource.List[current] = _sector; this.DialogResult = DialogResult.OK; this.Close(); } else { showValidationErrors(); //we clear the model state previous errors _modelState.Clear(); } } else//creating a new sector { if (_sectorService.CreateIndustrialSector(_sector)) { EasyCRMForm.getForm().sectorsBindingSource.Add(_sector); this.DialogResult = DialogResult.OK; this.Close(); } else { showValidationErrors(); _modelState.Clear(); //we clear the model state previous errors } } }
public ActionResult Create([Bind(Exclude = "Id")] IndustrialSector industrialSector) { if (!_sectorService.CreateIndustrialSector(industrialSector)) { return(View(industrialSector)); } return(RedirectToAction("Index")); }