Example #1
0
        public AjaxFormResult SaveBonus([BonusTaskBinder(Fetch = true)] BonusTask bonusTask)
        {
            var response = new AjaxFormResult();

            try
            {
                if (ViewData.ModelState.IsValid && bonusTask.IsValid())
                {
                    if (bonusTask.Id == 0)
                    {
                        bonusTask.Game = User.Game;
                        bonusTaskRepository.SaveOrUpdate(bonusTask);

                        response.ExtraParams["newID"] = bonusTask.Id.ToString();
                        response.ExtraParams["name"]  = bonusTask.Name;
                    }
                    response.Success = true;
                }
                else
                {
                    response.Success = false;
                    response.Errors.Add(new FieldError("BonusTask_ID", "The ID field is required"));

                    taskRepository.DbContext.RollbackTransaction();
                }
            }
            catch (Exception e)
            {
                response.Success            = false;
                response.ExtraParams["msg"] = e.ToString();
            }
            return(response);
        }
Example #2
0
        public AjaxFormResult SaveTip([TipBinder(Fetch = true)] Tip tip)
        {
            var response = new AjaxFormResult();

            try
            {
                if (ViewData.ModelState.IsValid && tip.IsValid())
                {
                    if (tip.Id == 0)
                    {
                        tipRepository.SaveOrUpdate(tip);

                        response.ExtraParams["newID"] = tip.Id.ToString();
                        response.ExtraParams["name"]  = tip.Name;
                    }
                    response.Success = true;
                }
                else
                {
                    response.Success = false;
                    response.Errors.Add(new FieldError("Tip_Id", "The TipID field is required"));

                    tipRepository.DbContext.RollbackTransaction();
                }
            }
            catch (Exception e)
            {
                response.Success            = false;
                response.ExtraParams["msg"] = e.ToString();
            }
            return(response);
        }
Example #3
0
        public AjaxFormResult SaveGame(Game game)
        {
            var response = new AjaxFormResult();

            try
            {
                Game gameToUpdate = gameRepository.Get(game.Id);
                TransferGameFormValuesTo(gameToUpdate, game);

                if (ViewData.ModelState.IsValid && game.IsValid())
                {
                    response.Success = true;
                }
                else
                {
                    response.Success = false;
                    response.Errors.Add(new FieldError("Game_ID", "The ID field is required"));
                }
            }
            catch (Exception e)
            {
                response.Success            = false;
                response.ExtraParams["msg"] = e.ToString();
            }
            return(response);
        }
Example #4
0
        public AjaxFormResult SaveTask([TaskBinder(Fetch = true)] Task task)
        {
            var response = new AjaxFormResult();

            try
            {
                if (ViewData.ModelState.IsValid && task.IsValid())
                {
                    if (task.Id == 0)
                    {
                        task.Game = User.Game;
                        Tip tip = new Tip {
                            Name = "Здесь должен быть текст задания...", SuspendTime = 0, Task = task
                        };
                        task.Tips.Add(tip);
                        tipRepository.SaveOrUpdate(tip);

                        response.ExtraParams["newID"] = task.Id.ToString();
                        response.ExtraParams["name"]  = task.Name;
                    }
                    response.Success = true;
                }
                else
                {
                    response.Success = false;
                    response.Errors.Add(new FieldError("Task_ID", "The CustomerID field is required"));

                    taskRepository.DbContext.RollbackTransaction();
                }
            }
            catch (Exception e)
            {
                response.Success            = false;
                response.ExtraParams["msg"] = e.ToString();
            }
            return(response);
        }