public void CreateFurnitureRequest(WoodFurnitureOrderModel model) { var ListsOfEqualsUserFurniture = _woodWorkshopRepository.Get(x => x.CustomerId == model.CustomerId); if (ListsOfEqualsUserFurniture != null) { var ListsOfEqualsUserFurnitureGrouppingByDate = ListsOfEqualsUserFurniture.GroupBy(x => x.Date); foreach (var list in ListsOfEqualsUserFurnitureGrouppingByDate) { if (list.Count() > 5) { throw new System.Exception("Users can't buy more than 5 item's in the same day "); } } } var ListOfNonAccessibleWoodType = _woodTypeRepository.GetByName("non-accessible"); if (ListOfNonAccessibleWoodType != null) { foreach (var item in ListOfNonAccessibleWoodType) { if (model.WoodTypeId == item.Id) { throw new System.Exception("This type of wood is non-accessible for now"); } } } var ListOfNonAccessibleFurnitureType = _furnitureTypeRepository.GetByName("non-accessible"); if (ListOfNonAccessibleFurnitureType != null) { foreach (var item in ListOfNonAccessibleFurnitureType) { if (model.FurnitureTypeId == item.Id) { throw new System.Exception("This type of furniture is non-accessible for now"); } } } var woodFurniture = _mapper.Map <WoodFurnitureOrder>(model); _woodWorkshopRepository.Create(woodFurniture); }
public void CreateFurnitureRequest(WoodFurnitureOrderModel model) { var ListOfAllItems = _woodWorkshopRepository.GetItemsByName(model.FullName); if (ListOfAllItems != null) { var ListsOfEqualsUserFurnitureOrders = ListOfAllItems.GroupBy(x => x.Date); foreach (var list in ListsOfEqualsUserFurnitureOrders) { if (list.Count() > 5) { throw new System.Exception("Users can't buy more than 5 item's in the same day "); } } } var woodFurniture = _mapper.Map <WoodFurnitureOrder>(model); _woodWorkshopRepository.Create(woodFurniture); }