Exemple #1
0
        private void createStoreButton_Click(object sender, EventArgs e)
        {
            CreateStore store = new CreateStore()
            {
                Name       = "Name of the store " + DateTime.Now.ToString(),
                Address    = "Address of the store",
                PostalCode = "Postal code",
                City       = "A place",
                Country    = "NL",
                Latitude   = 10.31,
                Longitude  = 20.21
            };

            using (Connection conn = NewConnection())
            {
                string result = conn.CreateStore(store);

                if (storeID == null)
                {
                    storeID = result;
                }

                AddLogLine(string.Format("ID of the created store: {0}", result));
            }
        }
 public async Task <IActionResult> Post([FromBody] CreateStore store)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest($"Server error"));
     }
     try
     {
         var InertStoreEntity = _mapper.Map <Store>(store);
         _repo.InsertStoreAsync(InertStoreEntity);
         if (!await _repo.SaveAllAsync())
         {
             return(StatusCode(500, "A problem happened with handling your request."));
         }
         return(Created("GetStore", InertStoreEntity));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemple #3
0
        public async Task <ActionResult> Create(StoreModel StoreUserCreationData, FormCollection form, LoadCompanies LoadCompaniesService, CreateStore CreateStoreService)
        {
            ViewBag.CompaniesList = new SelectList(LoadCompaniesService.LoadMultiCompanies(), "Id", "Name");

            ViewBag.error = "";
            StoreUserCreationData.CompanyId = new Guid(form["CompanyID"]);

            // Reciving values from list
            try
            {
                if (StoreUserCreationData.CompanyId == null || StoreUserCreationData.CompanyId == Guid.Empty)
                {
                    Console.Write(StoreUserCreationData.CompanyId);
                    ViewBag.error = "Please select a company the store shoude belong to.";
                    return(View());
                }
            }
            catch (Exception e)
            {
                ViewBag.error = viebagMessage(e);
            }

            try
            {
                await CreateStoreService.createStore(StoreUserCreationData);

                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                ViewBag.error = viebagMessage(e);

                return(View());
            }
        }