예제 #1
0
        public ActionResult PostEdit(InfoManageModel parm)
        {
            using (LoveBankDBContext db = new LoveBankDBContext())
            {

                var t_m = db.T_Machine;
                var t_a = db.T_InfoManage;
                var t_s = db.T_SourceFile;

                #region 初始化参数
                InfoManage model = t_a.Find(parm.ID);

                model.Title = parm.Title;
                model.Desc = parm.Desc;

                model.DeptId = parm.DeptId;
                model.LinkUrl = parm.Desc;
                model.Phone = parm.Desc;
                model.Contact = parm.Desc;
                model.Type = parm.Type;

                ///删除原来的,彻底以新增方式进行(修改通过删除在新增实现)
                var delSourceFile = from s in t_s where s.Guid == model.Guid select s;
                db.T_SourceFile.RemoveRange(delSourceFile);

                #endregion
                db.Update<InfoManage>(model);
                db.SaveChanges();

                db.T_SourceFile.AddRange(parm.SourceFileList);//重新绑定
                db.SaveChanges();

                return Success("添加成功");

            }
        }
예제 #2
0
        public ActionResult PostAdd(InfoManageModel parm)
        {
            #region 初始化参数
            InfoManage model = new InfoManage();

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

            model.Title = parm.Title;
            model.Desc = parm.Desc;
            model.LinkUrl = parm.LinkUrl;
            model.Contact = parm.Contact;
            model.Phone = parm.Phone;
            model.DeptId = parm.DeptId;
            model.Type = parm.Type;

            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("添加成功");

            }
        }