Пример #1
0
        /// <summary>
        /// companyList
        /// </summary>
        /// <param name="company"></param>
        private void SetIntroduceToCurrentArticle(int company_id,project_case proj)
        {
            try
            {
                if (proj.is_company_intro == 1)
                {
                    IList<project_case> list = Uof.Iproject_caseService.GetAll(p => p.company_id == company_id && p.Id != proj.Id).ToList();
                    if (list.Count > 0)
                    {
                        for (int i = 0; i < list.Count; i++)
                        {
                            list[i].is_company_intro = 0;
                        }

                        Uof.Iproject_caseService.UpdateEntities(list);

                    }
                }
            }
            catch(Exception ex)
            {
                LogHelper.LogError(ex.Message,ex);
            }
        }
Пример #2
0
        public ActionResult Save(string proj)
        {
            project_case project = new project_case();
            project = JsonConvert.DeserializeObject<project_case>(proj);
            if (project != null && project.Id > 0)
            {
                project.update_time = DateTime.Now;
                Uof.Iproject_caseService.UpdateEntity(project);
                AddLog("更新文章 文章ID:" + project.Id.ToString(), "更新文章", "成功");
                if (project.is_company_intro > 0)
                {
                    if (project.company_id.HasValue&&project.company_id.Value>0)
                    {
                        company com = Uof.IcompanyService.GetById(project.company_id.Value);
                        com.introduce_page_id = project.Id;
                        com.update_time = DateTime.Now;
                        Uof.IcompanyService.UpdateEntity(com);
                        SetIntroduceToCurrentArticle(com.Id,project);
                    }
                    return Json(new
                    {
                        result = true,
                        project_id = project.Id
                    });
                }
                return Json(new { result = true });
            }
            else if (project != null && project.Id == 0)
            {
                project.create_time = DateTime.Now;
                project.update_time = DateTime.Now;
                if (project.view_count == null)
                    project.view_count = 0;
                if (project.is_publish == null)
                {
                    project.is_publish = 0;
                }
                project = Uof.Iproject_caseService.AddEntity(project);
                AddLog("添加文章 文章ID:" + project.Id.ToString(), "添加文章", "成功");
                if (project.is_company_intro > 0)
                {

                    if (project.company_id.HasValue && project.company_id.Value > 0)
                    {
                        company com = Uof.IcompanyService.GetById(project.company_id.Value);
                        com.introduce_page_id = project.Id;
                        com.update_time = DateTime.Now;
                        Uof.IcompanyService.UpdateEntity(com);
                        SetIntroduceToCurrentArticle(com.Id, project);
                    }
                    return Json(new
                    {
                        result = true,
                        project_id = project.Id
                    });

                    //company com = Uof.IcompanyService.GetById(project.company_id.Value);
                    //com.introduce_page_id = project.Id;
                    //com.update_time = DateTime.Now;
                    //Uof.IcompanyService.UpdateEntity(com);
                    //return Json(new
                    //{
                    //    result = true,
                    //    project_id = project.Id
                    //});
                }
                else
                {
                    return Json(new
                    {
                        result = true,
                        project_id = project.Id
                    });
                }
            }
            else
            {
                return Json(new { result = false });
            }
        }