public int Register(User user, DateTime cartDate) { if (user == null) { throw new ArgumentNullException("User info not supplied"); } using (EF.APShopContext context = new EF.APShopContext()) { UnitOfWork uow = new UnitOfWork(context); EF.User dboUser = _mapper.Map <EF.User>(user); uow.Users.CreateUser(dboUser); EF.Cart dbCart = new EF.Cart() { DateLastUpdated = cartDate }; dboUser.Cart.Add(dbCart); //virtuelni clan uow.Commit(); return(dboUser.Id); } }
public Cart GetCartByUserId(int userId) { using (EF.APShopContext context = new EF.APShopContext()) { UnitOfWork uow = new UnitOfWork(context); EF.Cart efUserCart = uow.Carts.GetByUserId(userId); if (efUserCart is null) { return(null); } Cart cart = new Cart() { Id = efUserCart.Id, UserId = efUserCart.UserId, DateLastUpdated = efUserCart.DateLastUpdated }; return(cart); } }