Exemplo n.º 1
0
        //添加案例同时添加缩略图
        public int AddWebCase(WebCase webCase)
        {
            WebCompanyService comSer = new WebCompanyService();
            WebPeopleService  peoSer = new WebPeopleService();

            using (AIYunNetContext context = new AIYunNetContext())
            {
                context.WebCase.Add(webCase);

                string[] list = ImageHelper.GetHvtImgUrls(webCase.CaseInfo);
                foreach (var item in list)
                {
                    string     thum = ImageHelper.GetthumImgByUrl(item);
                    WebCaseImg img  = new WebCaseImg
                    {
                        CompanyID      = webCase.CompanyID,
                        CompanyName    = webCase.CompanyID == 0?"":comSer.GetWebCompanyByID(webCase.CompanyID).CompanyName,
                        PeopleID       = webCase.PeopleID,
                        PeopleName     = webCase.PeopleID == 0?"":peoSer.GetWebPeopleByID(webCase.PeopleID).PeopleName,
                        imgName        = webCase.CaseTitle,
                        Img            = item,
                        thumbnailImage = thum,
                        WebCaseID      = webCase.CaseID,
                        DecType        = webCase.DecType,
                        GzStyle        = webCase.GzStyle,
                        JzStyle        = webCase.Style
                    };
                    context.WebCaseImg.Add(img);
                }
                context.SaveChanges();
                return(1);
            }
        }
Exemplo n.º 2
0
        public int DeleteWebCase(int caseID)
        {
            WebCompanyService webCompanyService = new WebCompanyService();
            WebPeopleService  webPeopleService  = new WebPeopleService();

            using (AIYunNetContext context = new AIYunNetContext())
            {
                WebCase originalCase = context.WebCase.Find(caseID);
                if (originalCase != null)
                {
                    originalCase.FlagDelete = 1;
                    originalCase.DeleteOn   = DateTime.Now;
                    webCompanyService.updateCaseCountbyCompanyID(originalCase.CompanyID);
                    webPeopleService.updateCaseCountbyPeopleID(originalCase.PeopleID);
                    context.SaveChanges();
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
        }