示例#1
0
        public void AddItem(SportSupplementDTO item, int quantity)
        {
            CartLine        line = LineCollection.Where(g => g.SportSupplement.SportSupplementId == item.SportSupplementId).FirstOrDefault();
            SportSupplement data = new SportSupplement
            {
                SportSupplementId = item.SportSupplementId,
                CategoryName      = item.CategoryName,
                Date        = item.Date,
                Description = item.Description,
                Name        = item.Name,
                Price       = item.Price
            };

            if (line == null)
            {
                LineCollection.Add(new CartLine
                {
                    SportSupplement = data,
                    Quantity        = quantity
                });
            }
            else
            {
                line.Quantity += quantity;
            }
        }
示例#2
0
        public void CreateSportSuplement(SportSupplementDTO sportSupplementDTO)
        {
            SportSupplement sportSupplement = new SportSupplement
            {
                Description  = sportSupplementDTO.Description,
                Name         = sportSupplementDTO.Name,
                Price        = sportSupplementDTO.Price,
                Date         = sportSupplementDTO.Date,
                CategoryName = sportSupplementDTO.CategoryName
            };

            if (sportSupplementDTO == null)
            {
                throw new ValidationException("Don`t found data", "");
            }
            Database.SportSupplements.Create(sportSupplement);
            Database.Save();
        }