public LearningContentSummary(BrandDetail brand) { this.Id = brand.BrandID; this.Brand = brand.BrandName; this.Description = brand.BrandDescription; this.Image = brand.BrandImage; }
public void GetAllBrands_should_return_expected_items() { // Given var expectedBrand = new BrandDetail { BrandID = 6, BrandName = "Local content", BrandDescription = "Content hosted by your organisation on the DLS Tracking System.", BrandImage = null, ImageFileType = null, IncludeOnLanding = false, ContactEmail = null, OwnerOrganisationId = 0, Active = true, OrderByNumber = 6, BrandLogo = null, PopularityHigh = 177, }; var expectedIndexes = new [] { 1, 2, 3, 4, 6, 8, 9 }; // When var result = brandsDataService.GetAllBrands().ToList(); // Then result.Select(b => b.BrandID).Should().BeEquivalentTo(expectedIndexes); result.SingleOrDefault(b => b.BrandID == 6).Should().BeEquivalentTo(expectedBrand); }
/// <summary>新增品牌 /// </summary> /// <param name="goodsBrandInfo"></param> /// <param name="errorMessage"></param> /// <returns></returns> public bool AddBrand(GoodsBrandInfo goodsBrandInfo, out string errorMessage) { List <BrandQualificationDetailInfo> informationList = null; if (goodsBrandInfo.GoodsInformationList != null) { if (goodsBrandInfo.GoodsInformationList.Any()) { informationList = goodsBrandInfo.GoodsInformationList.Select(ConvertToBrandInformationInfo).ToList(); foreach (var informationInfo in informationList) { informationInfo.BrandID = goodsBrandInfo.BrandId; informationInfo.BrandQualificationName = goodsBrandInfo.Brand; } } } var request = new BrandDetail { BrandInfo = ConvertToBrandInfo(goodsBrandInfo), BrandQualificationList = informationList }; var result = GoodsServerClient.AddBrand(request); errorMessage = string.Empty; if (result == null) { errorMessage = "GMS连接异常"; } else if (!result.IsSuccess) { errorMessage = result.ErrorMsg; } return(result != null && result.IsSuccess); }
public void Index_calls_expected_methods_and_returns_view() { // Given const int brandId = 1; var brand = new BrandDetail { BrandID = brandId, BrandName = "Brand Name", }; A.CallTo(() => brandsService.GetPublicBrandById(brandId)).Returns(brand); var applications = Builder <ApplicationWithSections> .CreateListOfSize(10).All() .With(a => a.Sections = new List <Section>()).Build(); A.CallTo( () => courseService.GetApplicationsThatHaveSectionsByBrandId(A <int> ._) ).Returns(applications); // When var result = controller.Index(brandId); // Then using (new AssertionScope()) { A.CallTo(() => brandsService.GetPublicBrandById(1)).MustHaveHappened(); A.CallTo(() => courseService.GetApplicationsThatHaveSectionsByBrandId(1)).MustHaveHappened(); result.Should().BeViewResult().WithDefaultViewName(); } }
public bool AddBrandAndOutlet(string jsonData) { bool result = false; string GroupId = ""; try { JavaScriptSerializer json_serializer = new JavaScriptSerializer(); json_serializer.MaxJsonLength = int.MaxValue; object[] objData = (object[])json_serializer.DeserializeObject(jsonData); List <BrandDetail> lstBrands = new List <BrandDetail>(); List <OutletDetail> lstOutlets = new List <OutletDetail>(); foreach (Dictionary <string, object> item in objData) { GroupId = Convert.ToString(item["GroupId"]); BrandDetail objBrand1 = new BrandDetail(); objBrand1.BrandId = Convert.ToString(item["BrandId1"]); objBrand1.GroupId = Convert.ToString(item["GroupId"]); objBrand1.BrandName = Convert.ToString(item["Brand1Name"]); objBrand1.Category = Convert.ToString(item["Brand1Category"]); objBrand1.CreatedDate = DateTime.Now; lstBrands.Add(objBrand1); if (!string.IsNullOrEmpty(Convert.ToString(item["Brand2Name"]))) { BrandDetail objBrand2 = new BrandDetail(); objBrand2.BrandId = Convert.ToString(item["BrandId2"]); objBrand2.GroupId = Convert.ToString(item["GroupId"]); objBrand2.BrandName = Convert.ToString(item["Brand2Name"]); objBrand2.Category = Convert.ToString(item["Brand2Category"]); objBrand2.CreatedDate = DateTime.Now; lstBrands.Add(objBrand2); } foreach (Dictionary <string, object> itemOutlet in (object[])item["OutletJson"]) { OutletDetail objOutletDetail = new OutletDetail(); objOutletDetail.GroupId = Convert.ToString(item["GroupId"]); objOutletDetail.BrandId = Convert.ToString(itemOutlet["BrandId"]); objOutletDetail.OutletId = Convert.ToString(itemOutlet["OutletId"]); objOutletDetail.OutletName = Convert.ToString(itemOutlet["OutletName"]); objOutletDetail.City = Convert.ToString(itemOutlet["City"]); objOutletDetail.Address = Convert.ToString(itemOutlet["Area"]); objOutletDetail.PinCode = Convert.ToString(itemOutlet["Pincode"]); objOutletDetail.Latitude = Convert.ToString(itemOutlet["Geotags"]); //objOutletDetail.Latitude = Convert.ToString(itemOutlet["CashierCount"]); objOutletDetail.CreatedDate = DateTime.Now; lstOutlets.Add(objOutletDetail); } } result = CR.AddBrandAndOutlet(GroupId, lstBrands, lstOutlets); } catch (Exception ex) { newexception.AddException(ex, GroupId); } return(result); }
public void UpdateBrandDetail(BrandDetail branddetail) { var dbContextbranddetail = dbContext.BrandDetails.FirstOrDefault(b => b.BrandDetailId == branddetail.BrandDetailId); dbContextbranddetail.BrandId = branddetail.BrandId; dbContextbranddetail.EngineType = branddetail.EngineType; dbContextbranddetail.Power = branddetail.Power; dbContextbranddetail.Year = branddetail.Year; dbContext.SaveChanges(); }
public LearningContentViewModel( SearchSortFilterPaginationResult <ApplicationWithSections> result, IEnumerable <FilterModel> availableFilters, BrandDetail brand, IEnumerable <TutorialSummary> tutorials ) : base(result, true, availableFilters) { BrandId = brand.BrandID; Name = brand.BrandName; Description = brand.BrandDescription; Tutorials = tutorials.Select(t => new BrandTutorialSummaryViewModel(t)); Applications = result.ItemsToDisplay.Select(app => new BrandCourseViewModel(app)); }
public ActionResult UpdateBrand(BrandDetail cd, HttpPostedFileBase _BrandImage) { int poz = 0; if (ModelState.IsValid) { Tbl_Brand b = _unitOfWork.GetRepositoryInstance <Tbl_Brand>().GetFirstOrDefault(cd.BrandId); b = b != null ? b : new Tbl_Brand(); b.BrandName = cd.BrandName; if (_BrandImage != null) { for (int i = _BrandImage.FileName.Length - 4; i >= 0; i--) { if (_BrandImage.FileName[i] == '\\') { poz = i; break; } } } b.BrandImage = _BrandImage != null?_BrandImage.FileName.Substring(poz + 1) : b.BrandImage; if (cd.BrandId != 0) { _unitOfWork.GetRepositoryInstance <Tbl_Brand>().Update(b); _unitOfWork.SaveChanges(); } else { b.IsActive = true; b.IsDelete = false; _unitOfWork.GetRepositoryInstance <Tbl_Brand>().Add(b); } return(RedirectToAction("Brands")); if (_BrandImage != null) { uc.UploadImage(_BrandImage, b.BrandId + "_", "/Content/ProductImage/", Server, _unitOfWork, 0, b.BrandId, 0); } return(RedirectToAction("Products")); } else { return(View("UpdateBrand", cd)); } }
/// <summary> /// Update Brand /// </summary> /// <param name="brandId"></param> /// <returns></returns> public ActionResult UpdateBrand(int brandId) { BrandDetail cd; if (brandId != 0) { cd = _unitOfWork.GetRepositoryInstance <Tbl_Brand>().GetListByParameter(i => i.BrandId == brandId).Select(j => new BrandDetail { BrandId = j.BrandId, BrandName = j.BrandName, IsActive = j.IsActive ?? default(bool), IsDelete = j.IsDelete ?? default(bool) }).FirstOrDefault(); } // cd = JsonConvert.DeserializeObject<CategoryDetail>(JsonConvert.SerializeObject(_unitOfWork.GetRepositoryInstance<OnlineShopping.DAL.Tbl_Category>().GetFirstOrDefault(categoryId))); else { cd = new BrandDetail(); } return(View("UpdateBrand", cd)); }
static GoodsBrandInfo ConvertToGoodsBrandInfo(BrandDetail detail) { var infoList = new List <GoodsInformationInfo>(); if (detail.BrandQualificationList != null) { infoList.AddRange(detail.BrandQualificationList.Select(info => new GoodsInformationInfo { ExtensionName = info.ExtensionName, ID = info.BrandID, IdentifyId = info.BrandID, Name = info.BrandQualificationName, OverdueDate = info.OverdueDate, Path = info.Path, Type = 0, UploadDate = info.LastOperationTime })); } var brandInfo = ConvertToGoodsBrandInfo(detail.BrandInfo); brandInfo.GoodsInformationList = infoList; return(brandInfo); }
public IActionResult EditBrandDetail(BrandDetail brandDetail) { brandService.UpdateBrandDetail(brandDetail); return(RedirectToAction("GetListBrandDetail", "AdminEditManagment")); }
public void DeleteBrandDetail(BrandDetail branddetail) { dbContext.BrandDetails.Remove(branddetail); dbContext.SaveChanges(); }
public void AddBrandDetail(BrandDetail branddetail) { dbContext.BrandDetails.Add(branddetail); dbContext.SaveChanges(); }
public static async Task SeedData(IUserDatabaseService userDatabaseService , IPartnersDatabaseService partnersDatabase , IBrandsDatabaseService brandsDatabaseService , ICategoryDatabaseService categoryDatabaseService , IStatusDatabaseService statusDatabaseService) { if (partnersDatabase.GetPartners().Count == 0) { Partner partner = new Partner(); partner.Name = "Валкит ЛТД ЕООД"; partner.Bulstat = "6592345675"; partnersDatabase.AddPartner(partner); } if (brandsDatabaseService.GetBrands().Count == 0) { Brand brand = new Brand(); brand.Name = "БМВ"; BrandDetail brandDetail = new BrandDetail(); brandDetail.EngineType = "дизел"; brandDetail.Year = 2012; brandDetail.Power = 116; brandDetail.Brand = brand; brandsDatabaseService.AddBrandDetail(brandDetail); brandDetail.EngineType = "бензин"; brandDetail.Year = 2019; brandDetail.Power = 240; brandDetail.Brand = brand; brandsDatabaseService.AddBrandDetail(brandDetail); brand = new Brand(); brand.Name = "АУДИ"; brandDetail.EngineType = "бензин"; brandDetail.Year = 2008; brandDetail.Power = 109; brandDetail.Brand = brand; brandsDatabaseService.AddBrandDetail(brandDetail); brand = new Brand(); brand.Name = "Хюндай"; brandDetail.EngineType = "дизел"; brandDetail.Year = 2015; brandDetail.Power = 109; brandDetail.Brand = brand; brandsDatabaseService.AddBrandDetail(brandDetail); brand.Name = "Мерцедес"; brandDetail.EngineType = "газ"; brandDetail.Year = 2011; brandDetail.Power = 142; brandDetail.Brand = brand; brandsDatabaseService.AddBrandDetail(brandDetail); brandDetail.EngineType = "дизел"; brandDetail.Year = 2004; brandDetail.Power = 109; brandDetail.Brand = brand; brandsDatabaseService.AddBrandDetail(brandDetail); brand.Name = "Пежо"; brandDetail.EngineType = "бензин"; brandDetail.Year = 2008; brandDetail.Power = 109; brandDetail.Brand = brand; brandsDatabaseService.AddBrandDetail(brandDetail); Category category = new Category(); category.Name = "Аксесоари"; categoryDatabaseService.AddCategory(category); category.Name = "Спирачни дискове"; categoryDatabaseService.AddCategory(category); category.Name = "Гуми"; categoryDatabaseService.AddCategory(category); category.Name = "Накладки"; categoryDatabaseService.AddCategory(category); category.Name = "Автохимия"; categoryDatabaseService.AddCategory(category); category.Name = "Крушки за фарове"; categoryDatabaseService.AddCategory(category); category.Name = "Други"; categoryDatabaseService.AddCategory(category); Status status = new Status(); status.Name = "Очаква се обработка"; statusDatabaseService.AddStatus(status); status.Name = "Получена в офис"; statusDatabaseService.AddStatus(status); status.Name = "Изпратена от доставчик"; statusDatabaseService.AddStatus(status); status.Name = "Изпратена"; statusDatabaseService.AddStatus(status); status.Name = "Получена"; statusDatabaseService.AddStatus(status); status.Name = "Пренасочена към друг адрес"; statusDatabaseService.AddStatus(status); } }
public IActionResult AddBrandDetail(BrandDetail brandDetail) { brandService.AddBrandDetail(brandDetail); return(RedirectToAction("Index", "Home")); }
private void BrandViewExecuted(object sender, ExecutedRoutedEventArgs e) { var id = (int)e.Parameter; var bd = new BrandDetail(id, PageMode.ViewMode); bd.Show(); e.Handled = true; }
private void Button3Click(object sender, RoutedEventArgs e) { var bd = new BrandDetail(PageMode.AddMode); bd.Show(); }
private void BrandEditExecuted(object sender, ExecutedRoutedEventArgs e) { var brandId = (int) e.Parameter; var bd = new BrandDetail(brandId, PageMode.EditMode); bd.Show(); e.Handled = true; }