public ActionResult Create([DataSourceRequest]DataSourceRequest request, ViewModelType model)
        {
            var contest = this.Data.Contests.All().FirstOrDefault(c => c.Id == model.ContestId);
            var user = this.Data.Users.All().FirstOrDefault(u => u.Id == model.UserId);

            if (contest == null || user == null)
            {
                if (contest == null)
                {
                    ModelState.AddModelError("ContestId", "Невалидно състезание");
                }

                if (user == null)
                {
                    ModelState.AddModelError("UserId", "Невалиден потребител");
                }

                return this.GridOperation(request, model);
            }

            var participant = model.GetEntityModel();
            participant.Contest = contest;
            participant.User = user;

            model.Id = (int)this.BaseCreate(participant);
            model.UserName = user.UserName;
            model.ContestName = contest.Name;
            this.UpdateAuditInfoValues(model, participant);

            return this.GridOperation(request, model);
        }
Ejemplo n.º 2
0
        public ActionResult Create([DataSourceRequest] DataSourceRequest request, ViewModelType model)
        {
            var contest = this.Data.Contests.All().FirstOrDefault(c => c.Id == model.ContestId);
            var user    = this.Data.Users.All().FirstOrDefault(u => u.Id == model.UserId);

            if (contest == null || user == null)
            {
                if (contest == null)
                {
                    ModelState.AddModelError("ContestId", "Невалидно състезание");
                }

                if (user == null)
                {
                    ModelState.AddModelError("UserId", "Невалиден потребител");
                }

                return(this.GridOperation(request, model));
            }

            var participant = model.GetEntityModel();

            participant.Contest = contest;
            participant.User    = user;

            model.Id          = (int)this.BaseCreate(participant);
            model.UserName    = user.UserName;
            model.ContestName = contest.Name;
            this.UpdateAuditInfoValues(model, participant);

            return(this.GridOperation(request, model));
        }
        public ActionResult Create([DataSourceRequest]DataSourceRequest request, ViewModelType model)
        {
            var participant = model.GetEntityModel();
            var contest = this.Data.Contests.All().FirstOrDefault(c => c.Id == model.ContestId);
            var user = this.Data.Users.All().FirstOrDefault(u => u.Id == model.UserId);
            participant.Contest = contest;
            participant.User = user;
            this.BaseCreate(participant);

            model.UserName = user.UserName;
            model.ContestName = contest.Name;
            return this.GridOperation(request, model);
        }
        public ActionResult Create([DataSourceRequest] DataSourceRequest request, ViewModelType model)
        {
            if (!this.CheckIfUserHasContestPermissions(model.ContestId))
            {
                this.TempData[GlobalConstants.DangerMessage] = "Нямате привилегиите за това действие";
                return(this.RedirectToAction("Index", "Contests", new { area = "Administration" }));
            }

            var contest = this.Data.Contests.All().FirstOrDefault(c => c.Id == model.ContestId);
            var user    = this.Data.Users.All().FirstOrDefault(u => u.Id == model.UserId);

            if (contest == null || user == null)
            {
                if (contest == null)
                {
                    this.ModelState.AddModelError("ContestId", GlobalResource.Invalid_contest);
                }

                if (user == null)
                {
                    this.ModelState.AddModelError("UserId", GlobalResource.Invalid_user);
                }

                return(this.GridOperation(request, model));
            }

            var participant = model.GetEntityModel();

            participant.Contest = contest;
            participant.User    = user;

            model.Id          = (int)this.BaseCreate(participant);
            model.UserName    = user.UserName;
            model.ContestName = contest.Name;
            this.UpdateAuditInfoValues(model, participant);

            return(this.GridOperation(request, model));
        }
 public ActionResult Destroy([DataSourceRequest]DataSourceRequest request, ViewModelType model)
 {
     this.BaseDestroy(model.Id);
     return this.GridOperation(request, model);
 }
Ejemplo n.º 6
0
 public ActionResult Destroy([DataSourceRequest] DataSourceRequest request, ViewModelType model)
 {
     this.BaseDestroy(model.Id);
     return(this.GridOperation(request, model));
 }