예제 #1
0
 public ActionResult Create(BusStationModel model)
 {
     ViewBag.IsInsert = true;
     // does existing bus station
     if (_busStationService.GetList().Where(o => o.Name.ToLower() == model.Name.Trim().ToLower()).Count() == 0) // not existing, can insert
     {
         var    entity = _mapper.Map <BusStation>(model);
         string error  = _busStationService.Insert(entity);
         if (error != null)
         {
             ModelState.AddModelError(null, error);
             return(View("InsertOrUpdate", model));
         }
         else
         {
             return(RedirectToAction("Index"));
         }
     }
     else
     {
         ModelState.AddModelError(string.Empty, string.Format(Resource.ExistingNameOfError, Resource.BusStation));
         return(View("InsertOrUpdate", model));
     }
 }