예제 #1
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)));
            }
        }
예제 #2
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);
        }