public async Task <bool> createStore(StoreModel StoreUserCreationData) { bool returnbool; try { StoreModel Companyidcheck = await _StoreContextDB.Stores.FindAsync(StoreUserCreationData.id); while (Companyidcheck != null) { StoreUserCreationData.id = Guid.NewGuid(); Companyidcheck = _StoreContextDB.Stores.Find(StoreUserCreationData.id); } if (StoreUserCreationData.Longitude == null && StoreUserCreationData.Latitude == null) { try { ICordinatesModells RecivedApiCordinates = Servises.GoogleAdressToGeoPos.getCordByPos(StoreUserCreationData.Adress, StoreUserCreationData.City); StoreUserCreationData.Latitude = RecivedApiCordinates.lat; StoreUserCreationData.Longitude = RecivedApiCordinates.lng; } catch { throw; } } _StoreContextDB.Stores.Add(StoreUserCreationData); await _StoreContextDB.SaveChangesAsync(); returnbool = true; } catch { returnbool = false; throw; } return(returnbool); }
public async Task <ActionResult> Edit(StoreModel UserCreationData, FormCollection form) { StoresContext _StoreContextDB = new StoresContext(); ViewBag.error = ""; UserCreationData.CompanyId = new Guid(form["CompanyID"]); if (UserCreationData.Longitude == null && UserCreationData.Latitude == null) { try { ICordinatesModells RecivedApiCordinates = Servises.GoogleAdressToGeoPos.getCordByPos(UserCreationData.Adress, UserCreationData.City); UserCreationData.Latitude = RecivedApiCordinates.lat; UserCreationData.Longitude = RecivedApiCordinates.lng; } catch { throw; } } try { _StoreContextDB.Entry(UserCreationData).State = EntityState.Modified; await _StoreContextDB.SaveChangesAsync(); return(RedirectToAction("Index")); } catch (Exception e) { ViewBag.error = viebagMessage(e); return(View()); } }
public Application(ICordinatesModells CordinatesModells) { _CordinatesModells = CordinatesModells; }