public async Task <IActionResult> PostStock(Store store) { store.location = new Google.Cloud.Firestore.GeoPoint(-19.95685, 44.063343); await storeService.AddStore(store); return(CreatedAtAction("GetStock", new { id = store.cnpjStore }, store)); }
public void TestAddStore() { //Prepare StoreService storeService = new StoreService(); //Execute Store s1 = storeService.AddStore("Loja1", "Porto"); //Assert Assert.IsNotNull(s1); Assert.AreEqual("Loja1", s1.StoreName); Assert.AreEqual("Porto", s1.City); //Execute Store s2 = storeService.AddStore("Loja1", "Porto"); //Assert Assert.IsNull(s2); }
public IHttpActionResult PostStore(StoreDTO store) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } bool result = storeService.AddStore(store); return(CreatedAtRoute("DefaultApi", new { id = store.ID }, store)); }
public Boolean Post([FromBody] Store value) { //Will return true if successfully added the store provided or false if an error occurred try { return(MyService.AddStore(value)); } catch (Exception e) { return(false); } }
public IActionResult AddStore(Store store) { ViewBag.Me = userService.GetPersonBasedOnId(User.Identity.GetPersonId()); if (ModelState.IsValid) { store.StoreOwnerId = User.Identity.GetPersonId(); store.DateCreated = DateTime.Now; storeService.AddStore(store); return(RedirectToAction(nameof(Index))); } return(View(store)); }
private async void OnAddCommand(object obj) { var newStore = new Store { Name = AddStore.Name, Address = AddStore.Address, ModifiedDate = DateTime.Now, }; string json = JsonConvert.SerializeObject(newStore); await storeService.AddStore(json); OnRequestClose(); }
public async Task <Status> AddStore(Store store) { StoreValidation storeValidation = new StoreValidation(); Status status = Status.Success; store.StoreId = Guid.NewGuid(); try { if (await storeValidation.IsStoreValid(store)) { await storeService.AddStore(store); } else { status = Status.InvalidNameOrLocation; } } catch (Exception) { status = Status.DBError; } return(status); }
public void Add() { base.Status = 1; base.CreatedBy = AuthenticatedUser.GetUserFromIdentity().UserId; _StoreService.AddStore(this); }