예제 #1
0
        public ActionResult AjaxForm()
        {
            var customerType = new Customer_Type();

            if (DoAction == ActionType.Edit)
            {
                customerType = _customerTypeDa.GetById(ArrId.FirstOrDefault());
            }

            ViewData.Model     = customerType;
            ViewBag.Action     = DoAction;
            ViewBag.ActionText = ActionText;
            return(View());
        }
예제 #2
0
        public ActionResult Actions()
        {
            var msg          = new JsonMessage();
            var customerType = new Customer_Type();

            switch (DoAction)
            {
            case ActionType.Add:
                try
                {
                    customerType.IsDelete = false;
                    UpdateModel(customerType);
                    _customerTypeDa.Add(customerType);
                    _customerTypeDa.Save();
                    msg = new JsonMessage
                    {
                        Erros   = false,
                        ID      = customerType.ID.ToString(),
                        Message =
                            string.Format("Đã thêm mới hành động: <b>{0}</b>",
                                          Server.HtmlEncode(customerType.Name))
                    };
                }
                catch (Exception ex)
                {
                    LogHelper.Instance.LogError(GetType(), ex);
                }
                break;

            case ActionType.Edit:
                try
                {
                    customerType = _customerTypeDa.GetById(ArrId.FirstOrDefault());
                    UpdateModel(customerType);
                    _customerTypeDa.Save();
                    msg = new JsonMessage
                    {
                        Erros   = false,
                        ID      = customerType.ID.ToString(),
                        Message =
                            string.Format("Đã cập nhật chuyên mục: <b>{0}</b>",
                                          Server.HtmlEncode(customerType.Name))
                    };
                }
                catch (Exception ex)
                {
                    LogHelper.Instance.LogError(GetType(), ex);
                }
                break;

            case ActionType.Delete:
                var ltsCustomerTypeItems = _customerTypeDa.GetListByArrId(ArrId);
                var stbMessage           = new StringBuilder();
                foreach (var item in ltsCustomerTypeItems)
                {
                    item.IsDelete = true;
                }
                msg.ID = string.Join(",", ArrId);
                _customerTypeDa.Save();
                msg.Message = stbMessage.ToString();
                break;
            }

            if (string.IsNullOrEmpty(msg.Message))
            {
                msg.Message = "Không có hành động nào được thực hiện.";
                msg.Erros   = true;
            }

            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
 public void Delete(Customer_Type customerType)
 {
     FDIDB.Customer_Type.Remove(customerType);
 }
예제 #4
0
 public void Add(Customer_Type customerType)
 {
     FDIDB.Customer_Type.Add(customerType);
 }