public ProductCarPage(ProductCar carProduct = null) { InitializeComponent(); this.carproduct = carProduct; titleLabel.Text = carproduct == null ? "เพิ่มข้อมูล":"แก้ไขข้อมูล"; saveButton.Clicked += SaveButton_Clicked; cancelButton.Clicked += CancelButton_Clicked; tyepPicker.Items.Add("รถเก๋ง"); tyepPicker.Items.Add("รถกะบะ"); tyepPicker.Items.Add("รถตู้"); brandPicker.Items.Add("นิสสัน"); brandPicker.Items.Add("อีซูซุ"); brandPicker.Items.Add("บีเอ็มดับเบิลยู"); colorPicker.Items.Add("แดง"); colorPicker.Items.Add("ขาว"); colorPicker.Items.Add("ดำ"); colorPicker.Items.Add("เงิน"); provincePicker.Items.Add("กรุงเทพ"); provincePicker.Items.Add("ปทุมธานี"); provincePicker.Items.Add("พระนครศรีอยุธยา"); provincePicker.Items.Add("เพรชบุรี"); }
public IActionResult Delete(ProductCar productCar) { var result = _productService.DeleteToSystem(productCar); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public void Update(ProductCar product) { ProductCar productToUpdate = _cars.SingleOrDefault(p => p.Id == product.Id); productToUpdate.ModelYear = product.ModelYear; productToUpdate.Descriptions = product.Descriptions; productToUpdate.ColorId = product.ColorId; productToUpdate.BrandId = product.BrandId; productToUpdate.DailyPrice = product.DailyPrice; }
public void Add(ProductCar product) { if (_cars.SingleOrDefault(p => p.Id == product.Id) == null) { _cars.Add(product); } else { Console.WriteLine("Bu id numarası başka bir araca atılıdır." + _cars.Count + "ve önceki idler kullanılamaz!"); } }
public IResult UpdateToSystem(ProductCar product) { if (product.DailyPrice > 0) { _productdal.Update(product); return(new SuccessResult(Messages.ProductUpdated)); } else { return(new ErrorResult(Messages.DailyPriceError)); } }
async void SaveButton_Clicked(object sender, EventArgs e) { var isOk = await DisplayAlert("ยืนยัน", "คุณต้องการบันทึกหรือไม่", "ใช่", "ไม่ใช่"); if (isOk) { if (carproduct == null) { carproduct = new ProductCar(); carproduct.Category = tyepPicker.SelectedItem.ToString(); carproduct.Brand = brandPicker.SelectedItem.ToString(); carproduct.Gen = productNameEntry.Text; carproduct.Years = decimal.Parse(YearStepper.Text); carproduct.Miles = decimal.Parse(mileEntry.Text); carproduct.Color = colorPicker.SelectedItem.ToString(); carproduct.Deler = deronEntry.Text; carproduct.Description = detailsEntry.Text; carproduct.Price = decimal.Parse(priceEntry.Text); carproduct.Province = provincePicker.SelectedItem.ToString(); carproduct.Tel = decimal.Parse(tellEntry.Text); var id = App.DbHelper.AddProduct(carproduct); await DisplayAlert("บันทึกสำเส็จ", "รหัสรถของท่าน" + id, "ตกลง"); } else { carproduct = new ProductCar(); carproduct.Category = tyepPicker.SelectedItem.ToString(); carproduct.Brand = brandPicker.SelectedItem.ToString(); carproduct.Gen = productNameEntry.Text; carproduct.Years = decimal.Parse(YearStepper.Text); carproduct.Miles = decimal.Parse(mileEntry.Text); carproduct.Color = colorPicker.SelectedItem.ToString(); carproduct.Deler = deronEntry.Text; carproduct.Description = detailsEntry.Text; carproduct.Price = decimal.Parse(priceEntry.Text); carproduct.Province = provincePicker.SelectedItem.ToString(); carproduct.Tel = decimal.Parse(tellEntry.Text); var id = App.DbHelper.AddProduct(carproduct); await DisplayAlert("บันทึกสำเส็จ", "แก้ไขสินค้าเส็จแล้ว", "ตกลง"); } await Navigation.PopModalAsync(); } }
public int DeleteProduct(ProductCar product) { return(db.Delete(product)); }
public int UpdateProduct(ProductCar product) { return(db.Update(product)); }
public int AddProduct(ProductCar carProduct) { db.Insert(carProduct); return(carProduct.Id); }
public void Delete(ProductCar product) { ProductCar productToDelete = _cars.SingleOrDefault(p => p.Id == product.Id); _cars.Remove(productToDelete); }
public IResult DeleteToSystem(ProductCar product) { _productdal.Delete(product); return(new SuccessResult(Messages.ProductDeleted)); }
public IResult AddToSystem(ProductCar product) { _productdal.Add(product); return(new SuccessResult(Messages.ProductAdded)); }