Esempio n. 1
0
        private async Task InsertService()
        {
            if (ValidateInputs())
            {
                ServiceInsertVM serviceInsertVM = new ServiceInsertVM()
                {
                    Name  = TbName.Text,
                    Price = decimal.Parse(TbPrice.Text)
                };

                ls.LblLoading.Text = "Adding";
                ls.Show();
                bool success = await serviceApi.InsertService(serviceInsertVM);

                ls.Close();

                if (success)
                {
                    Close();
                }
                else
                {
                    MessageBox.Show("Fail!");
                }
            }
            else
            {
                MessageBox.Show("All input fields are required and price must be a number!");
            }
        }
Esempio n. 2
0
        public bool InsertService(ServiceInsertVM serviceInsertVM)
        {
            Service service = new Service()
            {
                Name  = serviceInsertVM.Name,
                Price = serviceInsertVM.Price
            };

            unitOfWork.Services.Add(service);

            int success = unitOfWork.Complete();

            return(success > 0);
        }
Esempio n. 3
0
        public async Task <bool> InsertService(ServiceInsertVM serviceInsertVM)
        {
            StringContent       content  = GetStringContent(serviceInsertVM);
            HttpClient          request  = new HttpClient();
            HttpResponseMessage response = await request.PostAsync($"{ API_URL }/InsertService", content);

            if (response.IsSuccessStatusCode)
            {
                bool result = await response.Content.ReadAsAsync <bool>();

                return(result);
            }
            return(false);
        }