Beispiel #1
0
        // PUT: api/GgcmsCategories/5
        public IHttpActionResult Edit(GgcmsMembers info)
        {
            var oldinfo = Dbctx.GgcmsMembers.Find(info.Id);

            if (oldinfo == null)
            {
                return(BadRequest("信息不存在"));
            }
            Dbctx.Entry(oldinfo).State = EntityState.Detached;

            //Dbctx.GgcmsMembers.Attach(info);
            //Dbctx.Entry(info).Property("goods_name").IsModified = true;
            //密码为空时,使用旧密码
            if (string.IsNullOrWhiteSpace(info.PassWord))
            {
                info.PassWord = oldinfo.PassWord;
            }
            var ent = Dbctx.Entry(info);

            ent.State = EntityState.Modified;
            Dbctx.SaveChanges();
            ClearCache();
            info.PassWord = "";
            return(Ok(info));
        }
Beispiel #2
0
        public IHttpActionResult ModifyPassword(dynamic passData)
        {
            string oldPassword = passData.oldPassword.ToString();
            string newPassword = passData.newPassword.ToString();
            string rePassword  = passData.rePassword.ToString();
            string sessionKey  = SystemEnums.login_user.ToString();

            if (Session[sessionKey] != null)
            {
                GgcmsMembers m    = Session[sessionKey] as GgcmsMembers;
                GgcmsMembers info = Dbctx.GgcmsMembers.Find(m.Id);
                if (info.PassWord != oldPassword)
                {
                    return(BadRequest("原密码不正确"));
                }
                else if (newPassword != rePassword)
                {
                    return(BadRequest("新密码和确认密码不同"));
                }
                else
                {
                    info.PassWord = newPassword;
                    var ent = Dbctx.Entry(info);
                    ent.Property("PassWord").IsModified = true;
                    Dbctx.SaveChanges();
                    Session.RemoveAll();
                }
                return(Ok(info));
            }
            return(BadRequest("请先登录"));
        }
Beispiel #3
0
        // PUT: api/GgcmsCategories/5
        public IHttpActionResult Edit(GgcmsPowers info)
        {
            if (Dbctx.GgcmsPowers.Where(x => x.Id == info.Id).Count() == 0)
            {
                return(BadRequest("信息不存在"));
            }
            //Dbctx.GgcmsPowers.Attach(info);
            //Dbctx.Entry(info).Property("goods_name").IsModified = true;
            var ent = Dbctx.Entry(info);

            ent.State = EntityState.Modified;
            Dbctx.SaveChanges();
            ClearCache();
            return(Ok(info));
        }
Beispiel #4
0
        // PUT: api/GgcmsCategories/5
        public IHttpActionResult Edit(GgcmsFriendLinks info)
        {
            if (Dbctx.GgcmsFriendLinks.Where(x => x.Id == info.Id).Count() == 0)
            {
                return(BadRequest("信息不存在"));
            }
            UpFileClass.FileSave(info, info.files);
            //Dbctx.GgcmsFriendLinks.Attach(info);
            //Dbctx.Entry(info).Property("goods_name").IsModified = true;
            var ent = Dbctx.Entry(info);

            ent.State = EntityState.Modified;
            Dbctx.SaveChanges();
            ClearCache();
            CacheHelper.RemoveAllCache(CacheTypeNames.Keys);
            return(Ok(info));
        }
Beispiel #5
0
        // PUT: api/GgcmsCategories/5
        public IHttpActionResult Edit(GgcmsTasks info)
        {
            if (Dbctx.GgcmsTasks.Where(x => x.Id == info.Id).Count() == 0)
            {
                return(BadRequest("信息不存在"));
            }
            //Dbctx.GgcmsTasks.Attach(info);
            //Dbctx.Entry(info).Property("goods_name").IsModified = true;
            info.SetNextRuntime();
            var ent = Dbctx.Entry(info);

            ent.State = EntityState.Modified;
            Dbctx.SaveChanges();
            ClearCache();
            CacheHelper.RemoveAllCache(CacheTypeNames.Tasks);
            return(Ok(info));
        }
Beispiel #6
0
        // PUT: api/GgcmsCategories/5
        public IHttpActionResult Edit(GgcmsCategories info)
        {
            if (Dbctx.GgcmsCategories.Where(x => x.Id == info.Id).Count() == 0)
            {
                return(BadRequest("信息不存在"));
            }
            info.RouteKey = HttpUtility.UrlEncode(info.RouteKey);
            UpFileClass.FileSave(info, info.files);

            //Dbctx.GgcmsCategories.Attach(info);
            //Dbctx.Entry(info).Property("goods_name").IsModified = true;
            var ent = Dbctx.Entry(info);

            ent.State = EntityState.Modified;
            Dbctx.SaveChanges();
            ClearCache();
            return(Ok(info));
        }
Beispiel #7
0
        // PUT: api/GgcmsCategories/5
        public IHttpActionResult Edit(GgcmsStyles info)
        {
            if (Dbctx.GgcmsStyles.Where(x => x.Id == info.Id).Count() == 0)
            {
                return(BadRequest("信息不存在"));
            }
            //Dbctx.Entry(info).Property("goods_name").IsModified = true;
            var qlist = from r in Dbctx.GgcmsStyles
                        where r.Id == info.Id
                        select r;
            GgcmsStyles oldinfo = qlist.First();

            info.Folder = oldinfo.Folder;
            //Dbctx.GgcmsStyles.Attach(info);
            var ent = Dbctx.Entry(info);

            ent.State = EntityState.Modified;
            Dbctx.SaveChanges();
            ClearCache();
            return(Ok(info));
        }
Beispiel #8
0
        // PUT: api/GgcmsCategories/5
        public IHttpActionResult Edit(GgcmsArticles info)
        {
            if (Dbctx.GgcmsArticles.Where(x => x.Id == info.Id).Count() == 0)
            {
                return(BadRequest("信息不存在"));
            }
            //Dbctx.GgcmsArticles.Attach(info);
            //Dbctx.Entry(info).Property("goods_name").IsModified = true;
            var ent = Dbctx.Entry(info);

            ent.State       = EntityState.Modified;
            info.pagesCount = info.pages.Where(x => x.state != EntityState.Deleted).Count() + 1;
            UpFileClass.FileSave(info, info.files.FindAll(x => x.fileType != 3));
            var old = Dbctx.GgcmsArticles.Find(info.Id);

            if (old.Category_Id != info.Category_Id)
            {
                updateArticleNumber(info.Category_Id, 1);
                updateArticleNumber(old.Category_Id, -1);
                CacheHelper.RemoveAllCache(CacheTypeNames.Categorys);
            }
            var list = Dbctx.GgcmsAttachments.Where(x => x.Articles_Id == info.Id).ToList();

            //附件
            foreach (GgcmsAttachments attach in list)
            {
                var item = info.attachments.Find(x => x.Id == attach.Id);
                if (item == null)
                {
                    Dbctx.GgcmsAttachments.Remove(attach);
                }
                else
                {
                    attach.AttaUrl    = item.AttaUrl;
                    attach.AttaTitle  = item.AttaTitle;
                    attach.Describe   = item.Describe;
                    attach.CreateTime = DateTime.Now;
                    attach.RealName   = item.RealName;
                }
            }
            foreach (GgcmsAttachments attach in info.attachments)
            {
                if (attach.Id == 0)
                {
                    attach.Articles_Id = info.Id;
                    attach.CreateTime  = DateTime.Now;
                    Dbctx.GgcmsAttachments.Add(attach);
                }
            }
            if (info.ModuleInfo != null)
            {
                info.ExtModelId = info.ModuleInfo.Id;
                if (old.ExtModelId > 0 && info.ExtModelId != old.ExtModelId)
                {
                    ExtendModule.Delete(info.Id, old.ExtModelId);
                }
                foreach (var file in info.files.FindAll(x => x.fileType == 3))
                {
                    foreach (var item in info.ModuleInfo.Columns)
                    {
                        if (item.ColName == file.propertyName)
                        {
                            item.Value = UpFileClass.FileSave(file.filePath.ToString(), item.Value.ToString(), (int)file.fileType);
                        }
                    }
                }
                ExtendModule.SaveData(info.Id, info.ModuleInfo);
            }
            else if (old.ExtModelId > 0)
            {
                ExtendModule.Delete(info.Id, old.ExtModelId);
            }
            //分页保存
            if (info.pages.Count > 0)
            {
                foreach (var page in info.pages)
                {
                    UpFileClass.FileSave(page, page.files);
                    if (page.state == EntityState.Added)
                    {
                        page.Article_Id = info.Id;
                        Dbctx.GgcmsArticlePages.Add(page);
                    }
                    else if (page.state == EntityState.Modified)
                    {
                        var pageEnt = Dbctx.Entry(page);
                        pageEnt.State = EntityState.Modified;
                    }
                    else if (page.state == EntityState.Deleted)
                    {
                        var p = Dbctx.GgcmsArticlePages.Find(page.Id);
                        if (p != null)
                        {
                            Dbctx.GgcmsArticlePages.Remove(p);
                        }
                    }
                    //只更新分页信息
                    else if (page.state == EntityState.Unchanged)
                    {
                        Dbctx.GgcmsArticlePages.Attach(page);
                        Dbctx.Entry(info).Property("OrderId").IsModified = true;
                    }
                }
            }
            Dbctx.SaveChanges();
            ClearCache();
            return(Ok(info));
        }