Ejemplo n.º 1
0
        public ActionResult AjaxView()
        {
            var pictureModel = _pictureDa.GetById(ArrId.FirstOrDefault());

            ViewData.Model = pictureModel;
            return(View());
        }
Ejemplo n.º 2
0
        public ActionResult Actions()
        {
            var msg = new JsonMessage();

            switch (DoAction)
            {
            case ActionType.Edit:
                msg = new JsonMessage(false, "Cập nhât dữ liệu thành công.");
                try
                {
                    var model = _da.GetById(ArrId.FirstOrDefault());
                    UpdateModel(model);
                    _da.Save();
                }
                catch (Exception)
                {
                    msg.Erros   = true;
                    msg.Message = "Dữ liệu chưa được cập nhật.";
                }
                break;

            case ActionType.Delete:
                msg = new JsonMessage(false, "Xóa dữ liệu thành công.");
                try
                {
                    var lst = _da.GetListArrId(ArrId);
                    foreach (var item in lst)
                    {
                        item.IsDeleted = true;
                    }
                    _da.Save();
                }
                catch (Exception ex)
                {
                    msg.Erros   = true;
                    msg.Message = "Dữ liệu chưa được xóa";
                }
                break;

            default:
                msg.Message = "Không có hành động nào được thực hiện.";
                msg.Erros   = true;
                break;
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        public ActionResult Update(string key)
        {
            var msg = new JsonMessage(false, "Cập nhât dữ liệu thành công.");

            try
            {
                if (key != Keyapi)
                {
                    return(Json(0, JsonRequestBehavior.AllowGet));
                }
                var model = _da.GetById(ItemId);
                UpdateModel(model);
                model.Name        = HttpUtility.UrlDecode(model.Name);
                model.Description = HttpUtility.UrlDecode(model.Description);
                _da.Save();
            }
            catch (Exception)
            {
                msg.Erros   = true;
                msg.Message = "Dữ liệu chưa được cập nhật.";
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }