Exemplo n.º 1
0
        public object AddVendor([FromBody] AddVendorRequest req)
        {
            req.CreatedBy = User.Identity.Name;
            var result = req.RunRequest(req);

            return(result);
        }
Exemplo n.º 2
0
        public ApiResponse AddVendor(AddVendorRequest request)
        {
            ApiResponse response = new ApiResponse();

            response.Id = inventoryManager.AddVendor(request);

            return(response);
        }
Exemplo n.º 3
0
 public async void AddVendor()
 {
     if (ValidateVendorData())
     {
         AddVendorRequest request = GetVendorData();
         ((App)App.Current).PostRequest <AddVendorRequest, ApiResponse>("AddVendor", request).ContinueWith(a => VendorAdded(a.Result));
     }
 }
Exemplo n.º 4
0
        public HttpResponseMessage AddVendor(AddVendorRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            ItemResponse <int> response = new ItemResponse <int>();

            response.Item = VendorsService.UpdateVendor(model);
            return(Request.CreateResponse(response));
        }
Exemplo n.º 5
0
        private AddVendorRequest GetVendorData()
        {
            AddVendorRequest addVendorRequest = new AddVendorRequest();

            addVendorRequest.Vendor.VendorName    = this.VendorName.Text;
            addVendorRequest.Vendor.VendorEmail   = this.VendorEmail.Text;
            addVendorRequest.Vendor.VendorPhone   = this.VendorPhone.Text;
            addVendorRequest.Vendor.StreetAddress = this.Address1.Text;
            addVendorRequest.Vendor.UnitAptSuite  = this.Address2.Text;
            addVendorRequest.Vendor.City          = this.City.Text;
            addVendorRequest.Vendor.State         = this.State.Text;
            addVendorRequest.Vendor.ZipCode       = this.Zip.Text;

            return(addVendorRequest);
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Add([FromBody] AddVendorRequest request)
        {
            try
            {
                var response = await _serviceProvider.HandlerAsync(request);

                return(new JsonResult(response));
            }
            catch (Exception ex)
            {
                return(new JsonResult(new ResponseBase()
                {
                    Result = -1, ResultInfo = ex.Message
                }));
            }
        }
Exemplo n.º 7
0
        public Vendor Map(AddVendorRequest request)
        {
            if (request == null)
            {
                return(null);
            }

            var vendorItem = new Vendor
            {
                Name         = request.Name,
                Type         = request.Type,
                ContactName  = request.ContactName,
                ContactEmail = request.ContactEmail,
                Address      = request.Address,
            };

            return(vendorItem);
        }
        public async Task <VendorResponse> AddVendorAsync(AddVendorRequest request)
        {
            var vendorItem = _vendorMapper.Map(request);

            var newUser = new Entities.AppUser {
                UserName = request.ContactEmail, Email = request.ContactEmail
            };
            bool isCreated = await _userRepository.SignUpAsync(newUser, "partyAgile21", "Vendor");

            if (isCreated)
            {
                vendorItem.UserId = newUser.Id;
            }

            var result = _vendorRepository.Add(vendorItem);

            await _vendorRepository.UnitOfWork.SaveChangesAsync();

            var vendorEvent = new VendorEvent
            {
                Vendor   = result,
                VendorId = result.Id,
                EventId  = request.EventId,
                Budget   = new Price {
                    Amount = request.Budget.Amount, Currency = request.Budget.Currency
                },
                DepositPaid = new Price {
                    Amount = request.DepositPaid.Amount, Currency = request.Budget.Currency
                }
            };

            _vendorEventRepository.Add(vendorEvent);
            await _vendorEventRepository.UnitOfWork.SaveChangesAsync();

            return(_vendorMapper.Map(result));
        }
Exemplo n.º 9
0
        public async Task <IActionResult> Post(AddVendorRequest request)
        {
            var result = await _vendorService.AddVendorAsync(request);

            return(Ok(result));
        }
Exemplo n.º 10
0
 public long AddVendor(AddVendorRequest request)
 {
     return(persistence.AddVendor(request));
 }
Exemplo n.º 11
0
        public void AddVendor()
        {
            try
            {
                AddVendorRequest addVendorRequest = new AddVendorRequest();

                if (String.IsNullOrEmpty(this.VendorName.Text))
                {
                    MessageBox.Show("The least you can do is enter a name...");
                    return;
                }

                addVendorRequest.Vendor.VendorName    = this.VendorName.Text;
                addVendorRequest.Vendor.VendorEmail   = this.VendorEmail.Text;
                addVendorRequest.Vendor.VendorPhone   = this.VendorPhone.Text;
                addVendorRequest.Vendor.StreetAddress = this.Address1.Text;
                addVendorRequest.Vendor.UnitAptSuite  = this.Address2.Text;
                addVendorRequest.Vendor.City          = this.City.Text;
                addVendorRequest.Vendor.State         = this.State.Text;
                addVendorRequest.Vendor.ZipCode       = this.Zip.Text;

                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri("http://localhost:9000/");
                //client.DefaultRequestHeaders.Add("appkey", "myapp_key");
                client.DefaultRequestHeaders.Accept.Add(
                    new MediaTypeWithQualityHeaderValue("application/json"));

                client.DefaultRequestHeaders.Add("EO-Header", wnd.User + " : " + wnd.Pwd);

                string jsonData = JsonConvert.SerializeObject(addVendorRequest);
                var    content  = new StringContent(jsonData, Encoding.UTF8, "application/json");
                HttpResponseMessage httpResponse = client.PostAsync("api/Login/AddVendor", content).Result;
                if (httpResponse.IsSuccessStatusCode)
                {
                    Stream       streamData = httpResponse.Content.ReadAsStreamAsync().Result;
                    StreamReader strReader  = new StreamReader(streamData);
                    string       strData    = strReader.ReadToEnd();
                    strReader.Close();
                    GetVendorResponse apiResponse = JsonConvert.DeserializeObject <GetVendorResponse>(strData);

                    //if (apiResponse.Messages.Count > 0)
                    //{
                    //    StringBuilder sb = new StringBuilder();
                    //    foreach (KeyValuePair<string, List<string>> messages in apiResponse.Messages)
                    //    {
                    //        foreach (string msg in messages.Value)
                    //        {
                    //            sb.AppendLine(msg);
                    //        }
                    //    }

                    //    MessageBox.Show(sb.ToString());
                    //}
                    //else
                    {
                        if (apiResponse.VendorList.Count == 1)
                        {
                            ClearEditFields();

                            list3.Add(apiResponse.VendorList[0]);
                            this.VendorListView.ItemsSource = null;
                            this.VendorListView.ItemsSource = list3;
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Error adding Vendor");
                }
            }
            catch (Exception ex)
            {
            }
        }