public CreateEditGiveawayDropViewModel(GiveawayDrop drop)
 {
     this.ID          = drop.ID;
     this.Name        = drop.Name;
     this.LowerBound  = drop.LowerBound;
     this.HigherBound = drop.HigherBound;
     this.Type        = drop.Type;
 }
Пример #2
0
 public IActionResult EditGiveawayDrop(int id)
 {
     if (_userService.GetOrCreateUser(User.Identity.Name).AuthLevel == Models.User.AuthType.Admin)
     {
         GiveawayDrop drop = this._giveawayDropRepository.Get(id);
         CreateEditGiveawayDropViewModel viewModel = new CreateEditGiveawayDropViewModel(drop);
         return(View(viewModel));
     }
     else
     {
         return(RedirectToAction("Index", "Admin", new { changeAction = "unauth" }));
     }
 }
Пример #3
0
        public IActionResult DeleteGiveawayDrop(int id)
        {
            if (_userService.GetOrCreateUser(User.Identity.Name).AuthLevel == Models.User.AuthType.Admin)
            {
                GiveawayDrop drop = this._giveawayDropRepository.Get(id);

                this._giveawayDropRepository.Delete(drop);

                return(RedirectToAction("ManageGiveawayDrops", "Admin", new { changeAction = "deleted" }));
            }
            else
            {
                return(RedirectToAction("Index", "Admin", new { changeAction = "unauth" }));
            }
        }
Пример #4
0
        public IActionResult EditGiveawayDrop(CreateEditGiveawayDropViewModel viewModel)
        {
            if (_userService.GetOrCreateUser(User.Identity.Name).AuthLevel == Models.User.AuthType.Admin)
            {
                if (ModelState.IsValid)
                {
                    GiveawayDrop drop = new GiveawayDrop();
                    drop.Name        = viewModel.Name;
                    drop.LowerBound  = viewModel.LowerBound;
                    drop.HigherBound = viewModel.HigherBound;
                    drop.Type        = viewModel.Type;

                    this._giveawayDropRepository.Add(drop);

                    return(RedirectToAction("ManageGiveawayDrops", new { changeAction = "updated" }));
                }
                return(View(viewModel));
            }
            else
            {
                return(RedirectToAction("Index", "Admin", new { changeAction = "unauth" }));
            }
        }