예제 #1
0
        private void buttonSmartWatch_Click(object sender, EventArgs e)
        {
            if (textBoxName.Text == string.Empty || textBoxPrice.Text == string.Empty)
            {
                errorProviderName.SetError(textBoxName, "Please enter a value to Name field");
                errorProviderPrice.SetError(textBoxPrice, "Please enter a value to Price field");
            }
            else
            {
                errorProviderName.Clear();
                errorProviderPrice.Clear();

                SmartWatchDto smartWatch = new SmartWatchDto();
                smartWatch.Name         = textBoxName.Text;
                smartWatch.Price        = Parsers.DecimalParse(textBoxPrice.Text);
                smartWatch.Description  = textBoxDescription.Text;
                smartWatch.Manufacturer = new ProductService.ManufacturerDto
                {
                    Id = ((ManufacturerService.ManufacturerDto)comboBoxManufacturer.SelectedItem).Id
                };
                smartWatch.InterfaceForConnecting = new ProductService.InterfaceForConnectingDto
                {
                    Id = ((ConnectionTypeService.InterfaceForConnectingDto)comboBoxConnectionType.SelectedItem).Id
                };
                smartWatch.ScreenDiagonal = Parsers.DoubleParse(textBoxScreenDiagonal.Text);
                smartWatch.Pulsometer     = checkBoxPulsometer.Checked;
                smartWatch.SimCard        = checkBoxSimCard.Checked;

                _productServiceClient.AddSmartWatch(smartWatch);
                MessageBox.Show("Book successfully added");
                Close();
            }
        }
예제 #2
0
 public HttpResponseMessage AddProduct(SmartWatchDto smartWatch)
 {
     try
     {
         if (smartWatch != null)
         {
             _smartWatchService.Value.Insert(smartWatch);
             return(Request.CreateResponse(HttpStatusCode.OK, "Ok"));
         }
         return(Request.CreateResponse(HttpStatusCode.BadRequest, "Model is not valid"));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
     }
 }
예제 #3
0
        private List <SmartWatchDto> ParseSmartWatches()
        {
            var smartWatches = new List <SmartWatchDto>();

            foreach (DataGridViewRow row in dataGridViewSmartWatches.Rows)
            {
                var name  = row.Cells["textBoxSmartWatchName"].Value?.ToString();
                var price = row.Cells["textBoxSmartWatchPrice"].Value?.ToString();
                if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(price))
                {
                    break;
                }
                var smartWatch = new SmartWatchDto();
                smartWatch.Name         = name;
                smartWatch.Price        = Parsers.DecimalParse(price);
                smartWatch.Description  = row.Cells["textBoxSmartWatchDescription"].Value?.ToString();
                smartWatch.Manufacturer = row.Cells["comboBoxSmartWatchManufacturer"].Value == null
                    ? null
                    : new ProductService.ManufacturerDto
                {
                    Id = (int)row.Cells["comboBoxSmartWatchManufacturer"].Value
                };
                smartWatch.InterfaceForConnecting = row.Cells["comboBoxSmartWatchInterfaceForConnection"].Value == null
                    ? null
                    : new ProductService.InterfaceForConnectingDto
                {
                    Id = (int)row.Cells["comboBoxSmartWatchInterfaceForConnection"].Value
                };
                smartWatch.ScreenDiagonal = Parsers.DoubleParse(row.Cells["textBoxSmartWatchScreenDiagonal"].Value?.ToString());
                smartWatch.Pulsometer     = (bool?)row.Cells["checkBoxSmartWatchPulsometer"].Value ?? false;
                smartWatch.SimCard        = (bool?)row.Cells["checkBoxSmartWatchSimCard"].Value ?? false;

                smartWatches.Add(smartWatch);
            }
            return(smartWatches);
        }
예제 #4
0
 public void AddProduct(SmartWatchDto smartWatch)
 {
     _smartWatchService.Value.Insert(smartWatch);
 }