public async Task <IActionResult> Create(PromotionCreateRequest request)
        {
            if (ModelState.IsValid)
            {
                var result = await _promotionServive.Create(request);

                if (result.IsSuccessed == true)
                {
                    TempData["result"]    = "Create Success";
                    TempData["IsSuccess"] = true;
                }
                else
                {
                    TempData["result"]    = result.Message;
                    TempData["IsSuccess"] = false;
                }
                return(RedirectToAction("Index", "promotion"));
            }
            else
            {
                TempData["IsSuccess"] = false;
                TempData["result"]    = string.Join(" | ", ModelState.Values
                                                    .SelectMany(v => v.Errors)
                                                    .Select(e => e.ErrorMessage));
                //ViewBag.IsSuccess = false;
                return(RedirectToAction("Index", "promotion"));
            }
        }
Ejemplo n.º 2
0
        public NotificationViewModel Create(ProductViewModel product)
        {
            var newProduct = new Product()
            {
                Id              = Guid.NewGuid(),
                BrandId         = product.BrandId,
                ProductGroupId  = product.ProductGroupId,
                ProductParentId = product.ProductParentId,
                Name            = product.Name,
                Code            = product.Code,
                Supply          = product.Supply,
                IsMainInGroup   = product.IsMainInGroup
            };

            newProduct.Cost   = Convert.ToDecimal(product.CostValue, CultureInfo.InvariantCulture);
            newProduct.Price  = Convert.ToDecimal(product.PriceValue, CultureInfo.InvariantCulture);
            newProduct.Weight = Convert.ToDecimal(product.WeightValue, CultureInfo.InvariantCulture);

            CompatibilityAjuster(newProduct, product.ProductInGroupId);

            _unitOfWork.Product.Add(newProduct);
            _unitOfWork.Commit();
            _fileService.UploadFiles(product.Files, newProduct.Id, "Product");

            _promotionService.Create(newProduct.Id, 25);

            var result = new NotificationViewModel()
            {
                Message = "Produto criado com sucesso.",
                Status  = true,
                Title   = "Sucesso!"
            };

            return(result);
        }
Ejemplo n.º 3
0
        public ActionResult <Promotion> PostPromotion(PromotionCreateRequest entity)
        {
            bool success = _proSer.Create(entity);

            if (success)
            {
                return(Ok(entity));
            }
            return(Problem("Create failed!"));
        }
        public async Task <IActionResult> Create(PromotionCreateRequest request)
        {
            if (ModelState.IsValid == false)
            {
                return(BadRequest(ModelState));
            }
            var result = await _promotionService.Create(request);

            if (result.IsSuccessed == false)
            {
                return(BadRequest(result));
            }
            return(Ok(result));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> PaymentSuccessful(string id, PromotionInput input)
        {
            var user = await _userManager.GetUserAsync(User);

            var userId = _userManager.GetUserId(User);

            if (user == null)
            {
                return(NotFound($"Unable to load user."));
            }

            if (userId != id)
            {
                return(NotFound($"Unable to load user."));
            }

            await _promotionService.Create(input.Id, id, PromotionEnum.AccountUpgrade, DateTime.Now, DateTime.Now.AddDays(30.0));

            //   return View();
            return(Redirect($"/identity/account/manage/"));
        }
Ejemplo n.º 6
0
        public IActionResult CreatePromotion([FromBody] PromotionDto promotionDto)
        {
            var promotionDtos = _mapper.Map <PromotionDto>(promotionDto);

            var promotion = _promotionService.Create(promotionDtos);

            var promotionToConsoles = _promotionService.AddPromCons(promotion.Id, promotionDtos.Consoles);


            return(Ok(new {
                Id = promotion.Id,
                PromotionName = promotion.PromotionName,
                PromitionDesc = promotion.PromotionDesc,
                Type = promotion.Price,
                AllTime = promotion.AllTime,
                DateStart = promotion.DateStart,
                DateEnd = promotion.DateEnd,
                HourStart = promotion.HourStart,
                HourEnd = promotion.HourEnd,
                PromCons = promotionToConsoles
            }));
        }