public RedirectToRouteResult AddToCart(CartService cart, int id) { var item = service.GetSportSupplement(id); SportSupplementDTO data = new SportSupplementDTO { SportSupplementId = item.SportSupplementId, CategoryName = item.CategoryName, Date = item.Date, Description = item.Description, Name = item.Name, Price = item.Price }; if (data == null) { throw new ValidationException("Don`t found datas", ""); } else { cart.AddItem(data, 1); } return(RedirectToAction("DisplaySportSuplement", "SportSupplement")); }
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(); }