public static void Reset() { _oshKosh = null; _carters = null; _crazy8 = null; _theChildrensPlace = null; _brands = null; }
public ActionResult Create(CreateBrandViewModel model) { var brand = new DataAccess.Brand(); brand.Name = model.Name; brand.Country = model.Country; repo.Create(brand); return(RedirectToAction("Index")); }
public ActionResult Edit(BrandViewModel model) { var brand = new DataAccess.Brand(); brand.Name = model.Name; brand.Country = model.Country; brand.ID = model.ID; repo.Save(brand); return(RedirectToAction("Index")); }
public void CreateBrand(DTO.Brand createdBrand) { CheckHelper.ArgumentNotNull(createdBrand, "createdBrand"); CheckHelper.ArgumentWithinCondition(createdBrand.IsNew(), "Brand is not new."); Container.Get <IValidateService>().CheckIsValid(createdBrand); CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "User is not logged in."); CheckHelper.WithinCondition(SecurityService.IsCurrentUserSeller, "Only seller can create brand."); var persistentService = Container.Get <IPersistentService>(); var doesAnotherBrandWithTheSameNameExist = persistentService .GetEntitySet <DataAccess.Brand>() .Any(b => b.Name == createdBrand.Name); if (doesAnotherBrandWithTheSameNameExist) { throw new BrandServiceException("Бренд с заданным названием уже существует."); } var brand = new DataAccess.Brand { Name = createdBrand.Name, Active = createdBrand.Active }; brand.UpdateTrackFields(Container); persistentService.Add(brand); persistentService.SaveChanges(); createdBrand.Id = brand.Id; createdBrand.CreateDate = brand.CreateDate; createdBrand.CreateUser = brand.CreatedBy.GetFullName(); createdBrand.ChangeDate = brand.ChangeDate; createdBrand.ChangeUser = brand.ChangedBy.GetFullName(); }
public DTO.Brand CreateBrand(DataAccess.Brand brand, bool includeOnlyActive = true) { CheckHelper.ArgumentNotNull(brand, "brand"); CheckHelper.ArgumentWithinCondition(!brand.IsNew(), "!brand.IsNew()"); return (_dtoCache.Get( brand, b => { var result = new DTO.Brand { Id = b.Id, Name = b.Name, Active = b.Active }; CopyTrackableFields(result, b); return result; })); }