public LocationsModel AddLocation(LocationsModel locationsModel) { Location location = locationsModel.ConvertToLocation(); DB.Locations.Add(location); //DB.SaveChanges(); locationsModel.LocID = location.LocId; return(locationsModel); }
public IActionResult AddLocation(LocationsModel locationModel) { try { if (!ModelState.IsValid) { return(BadRequest(ErrorHelper.ExtractErrors(ModelState))); } LocationsModel addedLocations = LocationLogic.AddLocation(locationModel); return(Created("api/CarModels" + addedLocations.LocID, addedLocations)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ErrorHelper.GetExceptionMessage(ex))); } }
public IActionResult GetOneGetCategoryLocation(int id) { try { LocationsModel Location = LocationLogic.GetLocation(id); if (Location == null) { return(NotFound($"id {id} not found")); } return(Ok(Location)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ErrorHelper.GetExceptionMessage(ex))); } }
public PhoneModel AddPhone(PhoneModel phoneModel) { LocationsModel locationsModel = new LocationsModel(); locationsModel.Latitude = phoneModel.Loc.Latitude; locationsModel.Longitude = phoneModel.Loc.Longitude; LocationLogic locationLogic = new LocationLogic(DB); locationsModel = locationLogic.AddLocation(locationsModel); phoneModel.LocID = locationsModel.LocID; Phone phone = phoneModel.ConvertToPhone(); DB.Phones.Add(phone); //DB.SaveChanges(); phoneModel.PhoneID = phone.PhoneId; return(phoneModel); }