Beispiel #1
0
        public ActionResult Edit()
        {
            log.Info("GET - UserController - Edit");
            ActionResult result = View();

            string username = User.Identity.Name;

            try
            {
                User currentUser = UserAdministration.GetUser(username);

                /// map userinformation to UserEditModel

                /// pass it to view()
            }
            catch (Exception ex)
            {
                if (ex is ArgumentNullException || ex is ArgumentException)
                {
                    TempData[Constants.MessageType.ERROR] = Messages.ERROR_UNKNOWN_USER;
                }
                else if (ex is Exception)
                {
                    TempData[Constants.MessageType.ERROR] = Messages.ERROR_COMMON;
                }

                result = RedirectToAction("Index", "Shop");
            }

            return(result);
        }
Beispiel #2
0
        public ActionResult Packs()
        {
            log.Info("GET - Shop - Packs");
            PackOverviewModel model = null;


            try
            {
                /// get data from logic
                List <CardPack> packs       = ShopAdministration.GetCardPacks();
                User            currentUser = UserAdministration.GetUser(User.Identity.Name);

                /// MAP data to view model
                /// in this case mapping will be done manually
                /// BUT you may make use of an automapper too
                model = new PackOverviewModel()
                {
                    AmountMoney = currentUser.AmountMoney
                };

                List <PackModel> packsModel = new List <PackModel>();

                foreach (var pack in packs)
                {
                    packsModel.Add(new PackModel()
                    {
                        Description = pack.Name,
                        Name        = pack.Name,
                        Price       = pack.Price,
                        ID          = pack.ID
                    });
                }
                model.Packs = packsModel;
            }
            catch (Exception)
            {
                TempData[Constants.MessageType.ERROR] = Messages.ERROR_COMMON;
            }

            return(View(model));
        }