コード例 #1
0
        public virtual LJsonResult AjaxDelete(TAggregateRoot model)
        {
            var result = new LResult(true);

            try
            {
                var customerRepository = this.Repository <TAggregateRoot>();

                var entity = customerRepository.Get(model.ID);
                if (entity != null)
                {
                    customerRepository.Delete(entity);
                }
                customerRepository.Context.Commit();
                customerRepository.Context.Dispose();
            }
            catch (Exception)
            {
                result = new LResult(false);
            }
            var json = new LJsonResult();

            json.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            json.Data = result;
            return(json);
        }
コード例 #2
0
        public virtual LJsonResult AjaxEdit(TAggregateRoot model)
        {
            var result = new LResult(true);

            try
            {
                this.Repository <TAggregateRoot>().Update(model);
            }
            catch (Exception)
            {
                result = new LResult(false);
            }
            var json = new LJsonResult();

            json.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            json.Data = result;
            return(json);
        }
コード例 #3
0
        public virtual LJsonResult AjaxGetByModel(Guid id)
        {
            var result = new LResult(true);

            try
            {
                var model = this.Repository <TAggregateRoot>().Get(id);
                result.Data = model;
            }
            catch (Exception)
            {
                result = new LResult(false);
            }
            var json = new LJsonResult();

            json.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            json.Data = result;
            return(json);
        }
コード例 #4
0
        public virtual LJsonResult AjaxDeleteList(IList <Guid> idList)
        {
            var result = new LResult(true);

            try
            {
                for (int i = 0; i < idList.Count; i++)
                {
                    var entity = this.Repository <TAggregateRoot>().Get(idList[i]);
                    this.Repository <TAggregateRoot>().Delete(entity);
                }
            }
            catch (Exception)
            {
                result = new LResult(false);
            }
            var json = new LJsonResult();

            json.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            json.Data = result;
            return(json);
        }
コード例 #5
0
        public virtual LJsonResult AjaxAdd(TAggregateRoot model)
        {
            var result = new LResult(true);

            try
            {
                var customerRepository = this.Repository <TAggregateRoot>();
                customerRepository.Insert(model);
                customerRepository.Context.Commit();
                customerRepository.Context.Dispose();
            }
            catch (Exception)
            {
                result = new LResult(false);
            }

            var json = new LJsonResult();

            json.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            json.Data = result;

            return(json);
        }