Esempio n. 1
0
        public SharedResultVM SaveDocSet(Domain.DocSet mo)
        {
            var vm = new SharedResultVM();

            var uinfo = Apps.LoginService.Get(HttpContext);

            if (string.IsNullOrWhiteSpace(mo.DsCode))
            {
                mo.DsCode       = Core.UniqueTo.LongId().ToString();
                mo.Uid          = uinfo.UserId;
                mo.DsStatus     = 1;
                mo.DsCreateTime = DateTime.Now;

                db.DocSet.Add(mo);

                var num = db.SaveChanges();
                vm.Set(num > 0);
            }
            else
            {
                var currmo = db.DocSet.Find(mo.DsCode);
                if (currmo.Uid != uinfo.UserId)
                {
                    vm.Set(SharedEnum.RTag.unauthorized);
                }
                else
                {
                    currmo.DsName   = mo.DsName;
                    currmo.DsRemark = mo.DsRemark;
                    currmo.DsOpen   = mo.DsOpen;
                    currmo.Spare1   = mo.Spare1;

                    db.DocSet.Update(currmo);

                    var num = db.SaveChanges();
                    vm.Set(num > 0);
                }
            }
            return(vm);
        }
Esempio n. 2
0
        public ActionResultVM SaveDocSet(Domain.DocSet mo)
        {
            var vm = new ActionResultVM();

            var uinfo = new Application.UserAuthService(HttpContext).Get();

            using (var db = new Data.ContextBase())
            {
                if (string.IsNullOrWhiteSpace(mo.DsCode))
                {
                    mo.DsCode       = Core.UniqueTo.LongId().ToString();
                    mo.Uid          = uinfo.UserId;
                    mo.DsStatus     = 1;
                    mo.DsCreateTime = DateTime.Now;

                    db.DocSet.Add(mo);
                }
                else
                {
                    var currmo = db.DocSet.Find(mo.DsCode);
                    if (currmo.Uid != uinfo.UserId)
                    {
                        vm.Set(ARTag.unauthorized);
                    }

                    currmo.DsName   = mo.DsName;
                    currmo.DsRemark = mo.DsRemark;
                    currmo.DsOpen   = mo.DsOpen;
                    currmo.Spare1   = mo.Spare1;

                    db.DocSet.Update(currmo);
                }
                var num = db.SaveChanges();

                vm.Set(num > 0);
            }

            return(vm);
        }
Esempio n. 3
0
        public string SaveDocSet(Domain.DocSet mo, string savetype)
        {
            string result = "fail";

            var uinfo = new Func.UserAuthAid(HttpContext).Get();

            using (var db = new ContextBase())
            {
                if (savetype == "add")
                {
                    mo.DsCode       = Core.UniqueTo.LongId().ToString();
                    mo.Uid          = uinfo.UserId;
                    mo.DsStatus     = 1;
                    mo.DsCreateTime = DateTime.Now;

                    db.DocSet.Add(mo);
                }
                else
                {
                    var currmo = db.DocSet.Find(mo.DsCode);
                    if (currmo.Uid != uinfo.UserId)
                    {
                        return("unauthorized");
                    }

                    currmo.DsName   = mo.DsName;
                    currmo.DsRemark = mo.DsRemark;
                    currmo.DsOpen   = mo.DsOpen;

                    db.DocSet.Update(currmo);
                }
                var num = db.SaveChanges();

                result = num > 0 ? "success" : "fail";
            }
            return(result);
        }