コード例 #1
0
        public ActionResult PostAdd(LoveBank_AdModel parm)
        {
            #region 初始化参数
            LoveBank_Ad model = new LoveBank_Ad();

            model.AddTime = DateTime.Now;
            model.AddUserId = AdminUser.ID;
            model.State = RowState.有效;
            model.Guid = Guid.NewGuid().ToString();

            model.LinkUrl = parm.LinkUrl;
            model.MachineCode = parm.MachineCode;
            model.Title = parm.Title;
            model.Desc = parm.Desc;
            foreach (var item in parm.SourceFileList)
            {
                item.Guid = model.Guid;
                item.AddTime = DateTime.Now;

            }
            #endregion

            using (LoveBankDBContext db = new LoveBankDBContext())
            {

                var t_m = db.T_Machine;

                var mDeptId = from m in t_m where model.MachineCode == m.MachineCode select new { m.DeptId, m.ID };
                var tmpObjMachine = mDeptId.SingleOrDefault();
                if (tmpObjMachine == null)
                {
                    return Error("机器唯未授权,请先授权");
                }

                model.DeptId = tmpObjMachine.DeptId.ToString();
                model.MachineId = tmpObjMachine.ID;
                db.Add(model);
                db.SaveChanges();

                db.T_SourceFile.AddRange(parm.SourceFileList);
                db.SaveChanges();

                return Success("添加成功");

            }
        }
コード例 #2
0
        public ActionResult PostAdd(LoveBank_AdModel parm)
        {
            #region 初始化参数
            LoveBank_Ad model = new LoveBank_Ad();

            model.AddTime = DateTime.Now;
            model.AddUserId = AdminUser.ID;
            model.State = RowState.有效;
            model.Guid = Guid.NewGuid().ToString();
            model.LinkUrl = parm.LinkUrl;
            model.Postion = parm.Postion;
            model.Title = parm.Title;
            model.Desc = parm.Desc;
            foreach (var item in parm.SourceFileList)
            {
                item.Guid = model.Guid;
                item.AddTime = DateTime.Now;

            }
            #endregion

            using (LoveBankDBContext db = new LoveBankDBContext())
            {

                db.Add(model);
                db.SaveChanges();
                db.T_SourceFile.AddRange(parm.SourceFileList);
                db.SaveChanges();

                return Success("添加成功");

            }
        }