public static IList<Product> RetrieveProducts(Product[] allProducts, Requester requester) { var products = new List<Product>(); foreach (var product in allProducts) { if (!product.CompanyID.HasValue) { products.Add(product); continue; } if (requester != null && requester.CompanyID.HasValue && product.CompanyID == requester.CompanyID) { products.Add(product); } } return products; }
public void UserDoesNotWorkForAnyCompany() { _requester = new Requester(); _products.Clear(); _retrievedProducts = null; }
public static void Save(Requester requester) { log.DebugFormat("Save requester with id '{0}'", requester.ID); var service = ServiceManager.GetService<RequesterService>(); var dto = new DataConverter<Requester>().Convert<RequesterDTO>(requester); int? requesterId; if (requester.IsNew) { requesterId = service.Create(dto); } else { service.Update(dto); requesterId = dto.ID; DataPortal.Instance.ResetCachedValue(typeof(Requester), requesterId); } var actionProcessor = new ActionProcessor(); requester.ID = requesterId; requester.UserID = requesterId; ActionTypeEnum actionTypeEnum = requester.IsNew ? ActionTypeEnum.Add : ActionTypeEnum.Update; actionProcessor.ProcessAction(actionTypeEnum, requester); }
public void UserWorksForCompany(int userCompanyId) { _requester = new Requester {CompanyID = userCompanyId}; _products.Clear(); _retrievedProducts = null; }