Esempio n. 1
0
        public LocationsModel AddLocation(LocationsModel locationsModel)
        {
            Location location = locationsModel.ConvertToLocation();

            DB.Locations.Add(location);
            //DB.SaveChanges();
            locationsModel.LocID = location.LocId;

            return(locationsModel);
        }
Esempio n. 2
0
        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)));
            }
        }
Esempio n. 3
0
        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)));
            }
        }
Esempio n. 4
0
        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);
        }