Пример #1
0
        public override void ExecuteResult(ControllerContext context)
        {
            AjaxFormResult response = new AjaxFormResult();
            response.Success = true;
            response.IsUpload = isUpload;

            if (isNew)
            {
                //response.ExtraParams["title"] = title ?? string.Empty;
                response.ExtraParams["newID"] = newID ?? string.Empty;

                //var modules = context.Controller.GetType().GetCustomAttributes(typeof(ModuleAuthorizeAttribute), false);
                //if (modules != null && modules.Length > 0)
                //{
                //    var module = modules[0] as ModuleAuthorizeAttribute;
                //    if (!ModuleAuthorizeService.HasPermission(module.module, ProcessTypes.Update))
                //        response.ExtraParams["hasUpdateRole"] = "0";
                //}
            }

            response.ExtraParams["title"] = title ?? string.Empty;
            response.ExtraParams["msg"] = "Save Success";
            //response.ExtraParams["msg"] = success ? "Save Success" : "Please check fields!";

            response.ExecuteResult(context);
        }
Пример #2
0
        public AjaxFormResult SaveForm(string txtName, string txtEmail, string txtComments)
        {
            AjaxFormResult result = new AjaxFormResult();

            result.Script = Ext.Web.Ext.Msg.Alert("Success", "Bug report sent").Serialize();

            return result;
        }
Пример #3
0
        public AjaxFormResult SaveForm(string txtName, string txtEmail, string txtComments)
        {
            AjaxFormResult result = new AjaxFormResult();

            result.Script = X.Msg.Alert("Success", "Bug report sent").ToScript();

            return(result);
        }
 public override void ExecuteResult(ControllerContext context)
 {
     AjaxFormResult response = new AjaxFormResult();
     response.Success = false;
     response.ExtraParams["hasPermission"] = "0";
     response.ExtraParams["msg"] = "You are not authorized to perform this action";
     response.ExecuteResult(context);
 }
Пример #5
0
 public override void ExecuteResult(ControllerContext context)
 {
     AjaxFormResult response = new AjaxFormResult();
     if (!success)
     {
         response.Success = false;
         response.ExtraParams["isSingle"] = count > 1 ? "0" : "1";
         response.ExtraParams["msg"] = count > 1 ? "Some records did not deleted!" : "This record did not deleted!";
     }
     response.ExecuteResult(context);
 }
Пример #6
0
        public override void ExecuteResult(ControllerContext context)
        {
            AjaxFormResult response = new AjaxFormResult();
            response.Success = true;
            response.IsUpload = isUpload;
            response.ExtraParams["newID"] = newID ?? string.Empty;

            response.ExtraParams["title"] = title ?? string.Empty;
            response.ExtraParams["msg"] = "Save Success";
            response.ExecuteResult(context);
        }
Пример #7
0
        public override void ExecuteResult(ControllerContext context)
        {
            AjaxFormResult response = new AjaxFormResult();
            response.Success = false;
            response.IsUpload = isUpload;

            var errors = ModelState.Where(e => e.Value.Errors.Any()).Select(e => new { Key = e.Key, Message = e.Value.Errors[0].ErrorMessage }).ToList();

            foreach (var error in errors)
                response.Errors.Add(new FieldError(error.Key, error.Message));

            response.ExtraParams["msg"] = "Please check fields!";

            response.ExecuteResult(context);
        }
Пример #8
0
        public override void ExecuteResult(ControllerContext context)
        {
            AjaxFormResult response = new AjaxFormResult();
            response.Success = false;
            response.IsUpload = isUpload;

            var errors = ModelState.Where(e => e.Value.Errors.Any()).Select(e => new { Key = e.Key, Message = e.Value.Errors[0].ErrorMessage }).ToList();

            string errorMessage = string.Empty;

            foreach (var error in errors)
            {
                if (error.Key.StartsWith("__notificationError__"))
                    errorMessage += string.Format("-{0}<br>", error.Message);
                else
                    response.Errors.Add(new FieldError(error.Key, error.Message));
            }

            response.ExtraParams["msg"] = string.IsNullOrEmpty(errorMessage) ? "Please check fields!" : string.Format("<div style=\"width: 180px; height: 64px; text-align: left; padding-top: 4px; padding-right: 3px; padding-bottom: 3px; padding-left: 8px;\">{0}</div>", errorMessage);

            response.ExecuteResult(context);
        }
        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;
        }
        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;
        }
        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;
        }
        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;
        }
Пример #13
0
        public AjaxFormResult SaveCustomer(string id, FormCollection values)
        {
            AjaxFormResult response = new AjaxFormResult();

            try
            {
                //for example
                if (string.IsNullOrEmpty(values["CompanyName"]))
                {
                    response.Success = false;
                    response.Errors.Add(new FieldError("CompanyName", "The CompanyName field is required"));
                    return(response);
                }

                bool isNew = false;

                Customer customer;

                if (string.IsNullOrEmpty(id))
                {
                    if (string.IsNullOrEmpty(values["CustomerID"]))
                    {
                        response.Success = false;
                        response.Errors.Add(new FieldError("CustomerID", "The CustomerID field is required"));
                        return(response);
                    }

                    customer            = new Customer();
                    customer.CustomerID = values["CustomerID"];
                    isNew = true;
                }
                else
                {
                    customer = (from c in this.DBContext.Customers where c.CustomerID == id select c).First();
                }

                customer.CompanyName  = values["CompanyName"];
                customer.Address      = values["Address"];
                customer.City         = values["City"];
                customer.ContactName  = values["ContactName"];
                customer.ContactTitle = values["ContactTitle"];
                customer.Country      = values["Country"];
                customer.Fax          = values["Fax"];
                customer.Phone        = values["Phone"];
                customer.PostalCode   = values["PostalCode"];
                customer.Region       = values["Region"];

                if (isNew)
                {
                    this.DBContext.Customers.InsertOnSubmit(customer);
                }

                this.DBContext.SubmitChanges();

                response.ExtraParams["newID"] = customer.CustomerID.ToString();
            }
            catch (Exception e)
            {
                response.Success            = false;
                response.ExtraParams["msg"] = e.ToString();
            }

            return(response);
        }
Пример #14
0
        public AjaxFormResult SaveCustomer(string id, FormCollection values)
        {
            AjaxFormResult response = new AjaxFormResult();

            try
            {
                //for example
                if (string.IsNullOrEmpty(values["CompanyName"]))
                {
                    response.Success = false;
                    response.Errors.Add(new FieldError("CompanyName", "The CompanyName field is required"));
                    return response;
                }

                bool isNew = false;

                Customer customer;

                if(string.IsNullOrEmpty(id))
                {
                    if (string.IsNullOrEmpty(values["CustomerID"]))
                    {
                        response.Success = false;
                        response.Errors.Add(new FieldError("CustomerID", "The CustomerID field is required"));
                        return response;
                    }
                    
                    customer = new Customer();
                    customer.CustomerID = values["CustomerID"];
                    isNew = true;
                }
                else
                {
                    customer = (from c in this.DBContext.Customers where c.CustomerID == id select c).First();
                }
                
                customer.CompanyName = values["CompanyName"];
                customer.Address = values["Address"];
                customer.City = values["City"];
                customer.ContactName = values["ContactName"];
                customer.ContactTitle = values["ContactTitle"];
                customer.Country = values["Country"];
                customer.Fax = values["Fax"];                
                customer.Phone = values["Phone"];
                customer.PostalCode = values["PostalCode"];
                customer.Region = values["Region"];

                if(isNew)
                {
                    this.DBContext.Customers.InsertOnSubmit(customer);
                }

                this.DBContext.SubmitChanges();

                response.ExtraParams["newID"] = customer.CustomerID.ToString();
            }
            catch (Exception e)
            {
                response.Success = false;
                response.ExtraParams["msg"] = e.ToString();
            }

            return response;
        }