Esempio n. 1
0
        async public Task <IActionResult> Offers(OffersViewModel model, string acceptButton, string rateButton, string rateValue, string rateComment)
        {
            if (!string.IsNullOrWhiteSpace(rateButton))
            {
                var result = _projectEngine.CommentItem(rateButton, rateValue, rateComment);

                if (result.Type == TransactionType.Success)
                {
                    if (model != null)
                    {
                        return(RedirectToRoute("offers", new { FilterTypeId = model.FilterTypeId }));
                    }
                    else
                    {
                        return(RedirectToRoute("offers"));
                    }
                }
                else
                {
                    SetPageContent("offers");

                    var user = await _userEngine.CurrentUser(_userManager.GetUserId(User));

                    var filterType = model != null ? (OfferFilterTypes)model.FilterTypeId : OfferFilterTypes.All;
                    model.Offers      = _projectEngine.GetUserOffers(user.Id, filterType);
                    model.FilterTypes = _projectEngine.GetOfferFilterTypes();

                    ModelState.AddModelError("", result.Message);
                    return(View(model));
                }
            }

            if (model != null)
            {
                return(RedirectToRoute("offers", new { FilterTypeId = model.FilterTypeId }));
            }
            else
            {
                return(RedirectToRoute("offers"));
            }
        }