public ActionResult Edit(BusStationModel model) { ViewBag.IsInsert = false; // does existing bus station var result = _busStationService.GetList().Where(o => o.IdBusStation != model.IdBusStation && o.Name == model.Name); if (result.Count() == 0) // not existing, can insert { var entity = _mapper.Map <BusStation>(model); string error = _busStationService.Update(entity); if (error != null) { ModelState.AddModelError(string.Empty, error); return(View("InsertOrUpdate", model)); } else { return(RedirectToAction("Index")); } } else { ModelState.AddModelError(string.Empty, string.Format(Resource.ExistingNameOfError, Resource.BusStation)); return(View("InsertOrUpdate", model)); } }