示例#1
0
        public async Task <ActionResult <string> > RemoveFavAd(ApiInputModel input)
        {
            var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
            var record = await this.favoriteService.GetFavoriteCarByUserAndCarIdAsync(input.CarId, userId);

            if (record != null)
            {
                await this.myAccountService.RemoveFavAdAsync(input.CarId, userId);

                return(this.Ok(new { output = "removed", carId = input.CarId }));
            }

            return(this.Ok());
        }
示例#2
0
        public async Task <ActionResult <string> > AddToFav(ApiInputModel input)
        {
            var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
            var record = await this.favoriteService.GetFavoriteCarByUserAndCarIdAsync(input.CarId, userId);

            if (record == null)
            {
                await this.myAccountService.AddAdToFavAsync(input.CarId, userId);

                return(this.Ok(new { output = "added" }));
            }

            return(this.Ok(new { output = "already added" }));
        }
示例#3
0
        public async Task <ActionResult <string> > AddCarForCompare(ApiInputModel input)
        {
            var car = await this.adService.GetCurrentCarAsync(input.CarId);

            var carViewModel = new ComparedCarViewModel
            {
                Cc               = car.Cc,
                Color            = car.Color,
                Door             = car.Door,
                EuroStandart     = car.EuroStandart,
                Extras           = car.Extras.Split(",", StringSplitOptions.RemoveEmptyEntries).ToList(),
                Fuel             = car.Fuel,
                Gearbox          = car.Gearbox,
                Horsepowers      = car.Horsepowers,
                ImgPath          = car.ImgsPaths.Split(",", StringSplitOptions.RemoveEmptyEntries).First().ToString(),
                Km               = car.Km,
                Make             = car.Make,
                Model            = car.Model,
                Modification     = car.Modification,
                Price            = car.Price,
                Type             = car.Type,
                Condition        = car.Condition,
                YearOfProduction = car.YearOfProduction.ToString("MM.yyyy"),
            };

            if (this.ViewData["firstCar"] == null)
            {
                this.ViewData["firstCar"] = carViewModel;
                this.HttpContext.Session.SetString("carModel", carViewModel.Model);

                return(this.Ok(new { result = "firstCar" }));
            }
            else if (this.ViewData["secondCar"] == null)
            {
                this.ViewData["secondCar"] = carViewModel;
                return(this.Ok(new { result = "secondCar" }));
            }
            else
            {
                return(this.Ok(new { result = "full" }));
            }
        }