Exemplo n.º 1
0
        public IActionResult Index()
        {
            User user = GetUser();
            List <StorePointsDto>        points  = StorePointsService.GetStorePoints(user);
            List <StorePointsHistoryDto> history = StorePointsHistoryService.GetStorePointsHistory(user);

            PointsDto dto = new PointsDto {
                StorePoints = points, StorePointsHistory = history
            };

            return(View(dto));
        }
Exemplo n.º 2
0
        public IActionResult AddPoints(int postId, int userId)
        {
            // this user should be the admin of the store
            User user = GetUser();

            Post post = Context.Post.Include(o => o.Store).FirstOrDefault(o => o.Id == postId);

            // chack if the store is owned by the user who call the endpoint
            if (post.Store.User != user)
            {
                return(RedirectToAction("Index"));
            }


            //User to add the points
            User clientUser = Context.User.FirstOrDefault(o => o.Id == userId);

            StorePoints storePoints = StorePointsService.CreateStorePoints(clientUser, post.Store, post);

            StorePointsHistoryService.SaveStorePointsHistory(storePoints, post);

            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
 public StorePointsController(WebAppContext context) : base(context)
 {
     StorePointsService        = new StorePointsService(context);
     StorePointsHistoryService = new StorePointsHistoryService(context);
 }