Exemplo n.º 1
0
        public string AddCulLecturerSingle(dynamic requestData)
        {
            try
            {
                CultivateInterflow ci = JsonConvert.DeserializeObject <CultivateInterflow>(JsonConvert.SerializeObject(requestData.Cultivate));

                List <Lecturer> l = JsonConvert.DeserializeObject <List <Lecturer> >(JsonConvert.SerializeObject(requestData.Lecturer));

                ci.UpdateTime   = DateTime.Now;
                ci.UpdatePerson = ci.CreatePerson;

                if (ci.Introduce.IndexOf("base64") > 0)
                {
                    string d = ci.Introduce;

                    foreach (string a in imgHandel.GetHtmlImageUrlList(d))
                    {
                        if (a.IndexOf(ImgHandle.DNS) < 0)
                        {
                            string[] asplit   = a.Split(',');
                            string   imgtype  = asplit[0].Substring(11, asplit[0].Length - 18);
                            string   filepath = imgHandel.Base64StringToImage(asplit[1], imgtype, "/pic/Lecturer");
                            d = d.Replace(a, filepath);
                        }
                    }
                    ci.Introduce = d;
                }


                db.CultivateInterflow.Add(ci);

                db.SaveChanges();

                foreach (Lecturer i in l)
                {
                    i.CuInterId = ci.CuInterId;
                    db.Lecturer.Add(i);
                }
                db.SaveChanges();

                return("OK");
            }
            catch (Exception)
            {
                return("No");
            }
        }
Exemplo n.º 2
0
        public string UpdateCultivate(CultivateInterflow cu)
        {
            var q = (from v in db.CultivateInterflow
                     where v.CuInterId == cu.CuInterId
                     select v).FirstOrDefault();

            cu.CuInterId = 0;

            q.CurriculumName = cu.CurriculumName;
            q.CurriculumType = cu.CurriculumType;
            q.Url            = cu.Url;
            q.Priority       = cu.Priority;
            q.IsDisplay      = cu.IsDisplay;
            q.Introduce      = cu.Introduce;

            if (q.Introduce.IndexOf("base64") > 0)
            {
                string d = q.Introduce;

                foreach (string a in imgHandel.GetHtmlImageUrlList(d))
                {
                    if (a.IndexOf(ImgHandle.DNS) < 0)
                    {
                        string[] asplit   = a.Split(',');
                        string   imgtype  = asplit[0].Substring(11, asplit[0].Length - 18);
                        string   filepath = imgHandel.Base64StringToImage(asplit[1], imgtype, "/pic/Lecturer");
                        d = d.Replace(a, filepath);
                    }
                }
                q.Introduce = d;
            }

            q.UpdatePerson = cu.UpdatePerson;
            q.UpdateTime   = DateTime.Now;
            db.Entry <CultivateInterflow>(q).State = EntityState.Modified;
            db.SaveChanges();



            return(null);
        }
Exemplo n.º 3
0
        public string UpdateCultivateLecturer(dynamic requestData)
        {
            try
            {
                CultivateInterflow cu       = JsonConvert.DeserializeObject <CultivateInterflow>(JsonConvert.SerializeObject(requestData.Cultivate));
                List <Lecturer>    lecturer = JsonConvert.DeserializeObject <List <Lecturer> >(JsonConvert.SerializeObject(requestData.Lecturers));

                #region 修改培训交流活动基本信息
                var q = (from v in db.CultivateInterflow
                         where v.CuInterId == cu.CuInterId
                         select v).FirstOrDefault();
                cu.CuInterId = 0;

                q.CurriculumName = cu.CurriculumName;
                q.CurriculumType = cu.CurriculumType;
                q.Url            = cu.Url;
                q.Priority       = cu.Priority;
                q.IsDisplay      = cu.IsDisplay;
                q.Introduce      = cu.Introduce;

                if (q.Introduce.IndexOf("base64") > 0)
                {
                    string d = q.Introduce;

                    foreach (string a in imgHandel.GetHtmlImageUrlList(d))
                    {
                        if (a.IndexOf(ImgHandle.DNS) < 0)
                        {
                            string[] asplit   = a.Split(',');
                            string   imgtype  = asplit[0].Substring(11, asplit[0].Length - 18);
                            string   filepath = imgHandel.Base64StringToImage(asplit[1], imgtype, "/pic/Lecturer");
                            d = d.Replace(a, filepath);
                        }
                    }
                    q.Introduce = d;
                }

                q.UpdatePerson = cu.UpdatePerson;
                q.UpdateTime   = DateTime.Now;
                db.Entry <CultivateInterflow>(q).State = EntityState.Modified;
                db.SaveChanges();
                #endregion


                #region 修改讲师,包含新增

                foreach (Lecturer i in lecturer)
                {
                    if (i.LecturerId == 0)
                    {
                        db.Lecturer.Add(i);
                        db.SaveChanges();
                    }
                    else
                    {
                        var qd = (from v in db.Lecturer
                                  where v.LecturerId == i.LecturerId
                                  select v).FirstOrDefault();
                        i.LecturerId = -1;

                        qd.CuInterId    = i.CuInterId;
                        qd.HeadPicUrl   = i.HeadPicUrl;
                        qd.HotelName    = i.HotelName;
                        qd.LecturerName = i.LecturerName;
                        qd.Post         = i.Post;
                        db.Entry <Lecturer>(qd).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                }



                #endregion

                return("OK");
            }
            catch (Exception)
            {
                return("No");
            }
        }