public ActionResult CreateStation(StationCreateViewModel model) { if (!ModelState.IsValid) { return(BadRequest("Invalid Request")); } var createResult = _stationService.CreateStation(model); if (createResult == false) { return(StatusCode((int)HttpStatusCode.NotAcceptable, createResult)); } return(Ok()); }
public bool CreateStation(StationCreateViewModel model) { if (_StationRepository.Get(x => x.Deleted == false && x.Name.ToLower().Equals(model.Name.ToLower()) ) == null) { var station = new Station(); station.Name = model.Name; station.CityId = model.CityId; station.CreatedAtUTC = DateTime.UtcNow; _StationRepository.Add(station); _unitOfWork.CommitChanges(); return(true); } return(false); }