Exemple #1
0
        public virtual ActionResult CreateRPClassifiedAd(RPClassifiedAdDetail input)
        {
            input.SetNullsToEmptyStrings();
            var userId = User.Identity.GetUserId();

            try
            {
                DomainRegistry.Repository.Execute(new CreateRPClassifiedAd()
                {
                    UserId             = userId,
                    Title              = input.Title,
                    Text               = input.Text,
                    YesThemes          = input.YesThemes,
                    NoThemes           = input.NoThemes,
                    PreferredTimezones = input.PreferredTimezones
                });
            }
            catch (RPClassifiedAdInvalidInputException ex)
            {
                TempData["input"]    = input;
                TempData["Error"]    = ex.UserFriendlyError ?? ex.Message;
                TempData["SubError"] = ex.UserFriendlySubError;
                return(RedirectToAction(MVC.Settings.CreateRPClassifiedAd()));
            }
            catch (RPClassifiedAdLimitException ex)
            {
                TempData["Error"]    = ex.UserFriendlyError ?? ex.Message;
                TempData["SubError"] = ex.UserFriendlySubError;
                return(RedirectToAction(MVC.Settings.MyRPClassifiedAds()));
            }
            catch (UserNotFoundException ex)
            {
                TempData["Error"]    = ex.UserFriendlyError ?? ex.Message;
                TempData["SubError"] = ex.UserFriendlySubError;
                return(RedirectToAction(MVC.PvP.Play()));
            }

            TempData["Result"] = "RP classified ad successfully created.";
            return(RedirectToAction(MVC.Settings.MyRPClassifiedAds()));
        }
Exemple #2
0
        public virtual ActionResult UpdateRPClassifiedAd(RPClassifiedAdDetail input)
        {
            var userId = User.Identity.GetUserId();

            try
            {
                DomainRegistry.Repository.Execute(new UpdateRPClassifiedAd()
                {
                    RPClassifiedAdId = input.Id,
                    UserId           = userId,

                    Title              = input.Title,
                    Text               = input.Text,
                    YesThemes          = input.YesThemes,
                    NoThemes           = input.NoThemes,
                    PreferredTimezones = input.PreferredTimezones
                });
            }
            catch (RPClassifiedAdInvalidInputException ex)
            {
                TempData["input"]    = input;
                TempData["Error"]    = ex.UserFriendlyError ?? ex.Message;
                TempData["SubError"] = ex.UserFriendlySubError;
                return(RedirectToAction(MVC.Settings.UpdateRPClassifiedAd()));
            }
            catch (RPClassifiedAdException ex)
                when(ex is RPClassifiedAdNotOwnerException ||
                     ex is RPClassifiedAdNotFoundException)
                {
                    TempData["Error"]    = ex.UserFriendlyError ?? ex.Message;
                    TempData["SubError"] = ex.UserFriendlySubError;
                    return(RedirectToAction(MVC.Settings.MyRPClassifiedAds()));
                }

            TempData["Result"] = "RP classified ad successfully updated.";
            return(RedirectToAction(MVC.Settings.MyRPClassifiedAds()));
        }