public IActionResult RegisterBrand([FromBody] Brand brand) { try { Brand result = BrandHelpers.RegisterBrand(brand); if (result != null) { return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = result })); } return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = "Registration Failed" })); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
public IActionResult UpdateBrand([FromBody] Brand brands) { if (brands == null) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = $"{nameof(brands)} cannot be null" })); } try { Brand result = BrandHelpers.UpdateBrand(brands); if (result != null) { return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = brands })); } return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = "Updation Failed" })); } catch (Exception ex) { return(BadRequest(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
public IActionResult GetBbrandList() { try { var brandList = BrandHelpers.GetBrands(); if (brandList.Count > 0) { dynamic expando = new ExpandoObject(); expando.BrandList = brandList; return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = expando })); } return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = "No Data Found." })); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
private void BtnOk_Click(object sender, RoutedEventArgs e) { if (lstBrands.SelectedItem == null) { return; } SelectedBrand = BrandHelpers.GetBrand((string)lstBrands.SelectedItem); this.Close(); }
public IActionResult GetBrandCompaniesList() { try { dynamic expando = new ExpandoObject(); expando.GetBrandCompaniesList = BrandHelpers.GetCompaniesList().Select(x => new { ID = x.CompanyCode, TEXT = x.Name }); return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = expando })); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
public IActionResult GetBrandsList() { try { dynamic expando = new ExpandoObject(); expando.BrandsList = BrandHelpers.GetBrands(); return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = expando })); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
public async Task Update_product_brand() { var product = await CreateValidProduct(); var repository = new ProductRepository(fixture.context); var sut = await repository.GetProductFullAsync(product.Id); Assert.True(await repository.ExistsAsync(product.Id)); Assert.NotNull(sut); var newBrand = await BrandHelpers.CreateValidBrand(); await UpdateProductBrand(sut.Id, newBrand); sut = await repository.LoadFullProductTrackedAsync(sut.Id); await fixture.context.Entry(sut).ReloadAsync(); Assert.Equal(newBrand.Id, sut.Brand.Id); }
void LoadBrand() { if (string.IsNullOrEmpty(Properties.Settings.Default.Brand)) { var bw = new BrandWindow(); bw.ShowDialog(); if (!bw.SelectedBrand.HasValue) { MessageBox.Show("You must select a brand!"); Environment.Exit(100); return; } Properties.Settings.Default.Brand = bw.SelectedBrand.Value.GetName(); Properties.Settings.Default.Save(); } _brand = BrandHelpers.GetBrand(Properties.Settings.Default.Brand); Title = _brand.GetDisplayName() + " Vehicle Control"; }
public IActionResult DeleteBrand(string code) { if (string.IsNullOrWhiteSpace(code)) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = $"{nameof(code)} cannot be null" })); } try { Brand result = BrandHelpers.DeleteBrand(code); if (result != null) { return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = code })); } else { return(BadRequest(new APIResponse() { status = APIStatus.FAIL.ToString(), response = "Deletion Failed" })); } } catch (Exception ex) { return(BadRequest(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }