Exemplo n.º 1
0
        public override DeleteCircleInfoResponseBody ExecuteCore()
        {
            DeleteCircleInfoResponseBody res = new DeleteCircleInfoResponseBody();

            t_circle model = db.t_circle.Where(l => l.id == this.request.CircleId).FirstOrDefault();

            if (model != null)
            {
                db.t_circle.Remove(model);

                //var imgs = db.t_circle_image.Where(l => l.circle_id == this.request.CircleId).ToList();
                //if (imgs != null && imgs.Count > 0)
                //{
                //    db.t_circle_image.RemoveRange(imgs);
                //}

                var comments = db.t_circle_comment.Where(l => l.circle_id == this.request.CircleId).ToList();
                if (comments != null && comments.Count > 0)
                {
                    db.t_circle_comment.RemoveRange(comments);
                }

                var likes = db.t_circle_like.Where(l => l.circle_id == this.request.CircleId).ToList();
                if (likes != null && likes.Count > 0)
                {
                    db.t_circle_like.RemoveRange(likes);
                }

                db.SaveChanges();
                res.Status = ResultStatus.Success;
            }

            return(res);
        }
Exemplo n.º 2
0
        public override DeleteCircleInfoResponseBody ExecuteCore()
        {
            DeleteCircleInfoResponseBody res = new DeleteCircleInfoResponseBody();

            using (HWLEntities db = new HWLEntities())
            {
                t_circle model = db.t_circle.Where(l => l.id == this.request.CircleId).FirstOrDefault();
                if (model != null)
                {
                    db.t_circle.Remove(model);

                    //try
                    //{
                    var imgs = db.t_circle_image.Where(l => l.circle_id == this.request.CircleId).ToList();
                    if (imgs != null && imgs.Count > 0)
                    {
                        db.t_circle_image.RemoveRange(imgs);
                    }

                    var comments = db.t_circle_comment.Where(l => l.circle_id == this.request.CircleId).ToList();
                    if (comments != null && comments.Count > 0)
                    {
                        db.t_circle_comment.RemoveRange(comments);
                    }

                    var likes = db.t_circle_like.Where(l => l.circle_id == this.request.CircleId).ToList();
                    if (likes != null && likes.Count > 0)
                    {
                        db.t_circle_like.RemoveRange(likes);
                    }

                    db.SaveChanges();
                    res.Status = ResultStatus.Success;
                    //}
                    //catch (Exception)
                    //{
                    //    //可以忽略这个错误
                    //}
                }
            }

            return(res);
        }
Exemplo n.º 3
0
        public override AddCircleInfoResponseBody ExecuteCore()
        {
            AddCircleInfoResponseBody res = new AddCircleInfoResponseBody();

            using (HWLEntities db = new HWLEntities())
            {
                t_circle model = new t_circle()
                {
                    user_id        = this.request.UserId,
                    circle_content = this.request.Content,
                    content_type   = GetContentType(),
                    link_image     = this.request.LinkImage,
                    link_title     = this.request.LinkTitle,
                    link_url       = this.request.LinkUrl,
                    lat            = this.request.Lat,
                    lon            = this.request.Lon,
                    id             = 0,
                    pos_id         = this.request.PosId,
                    pos_desc       = this.request.PosDesc,
                    comment_count  = 0,
                    image_count    = this.request.Images != null ? this.request.Images.Count : 0,
                    like_count     = 0,
                    publish_time   = DateTime.Now,
                    update_time    = DateTime.Now,
                };
                db.t_circle.Add(model);
                db.SaveChanges();

                res.CircleId    = model.id;
                res.ContentType = model.content_type;
                res.PublishTime = model.publish_time;

                if (res.CircleId > 0)
                {
                    if (this.request.Images != null && this.request.Images.Count > 0)
                    {
                        //添加图片
                        List <t_circle_image> imgModels = new List <t_circle_image>();
                        this.request.Images.ForEach((i) =>
                        {
                            if (string.IsNullOrEmpty(i.Url))
                            {
                                return;
                            }
                            imgModels.Add(new t_circle_image()
                            {
                                circle_id = model.id,
                                user_id   = model.user_id,
                                image_url = i.Url,
                                height    = i.Height,
                                width     = i.Width
                            });
                        });

                        if (imgModels == null || imgModels.Count <= 0)
                        {
                            return(res);
                        }

                        try
                        {
                            db.t_circle_image.AddRange(imgModels);
                            db.SaveChanges();
                        }
                        catch (Exception)
                        {
                            //可以忽略这个错误
                        }
                    }
                }
            }
            return(res);
        }
Exemplo n.º 4
0
        public override AddCircleInfoResponseBody ExecuteCore()
        {
            AddCircleInfoResponseBody res = new AddCircleInfoResponseBody();
            t_circle model = new t_circle()
            {
                user_id       = this.request.UserId,
                content_info  = this.request.Content,
                content_type  = GetContentType(),
                link_image    = this.request.LinkImage,
                link_title    = this.request.LinkTitle,
                link_url      = this.request.LinkUrl,
                lat           = this.request.Lat,
                lon           = this.request.Lon,
                id            = 0,
                image_urls    = CircleImageParser.GetImageString(this.request.Images),
                pos_desc      = this.request.PosDesc,
                comment_count = 0,
                image_count   = this.request.Images != null ? this.request.Images.Count : 0,
                like_count    = 0,
                publish_time  = DateTime.Now,
                update_time   = DateTime.Now,
            };

            db.t_circle.Add(model);
            db.SaveChanges();

            res.CircleId    = model.id;
            res.ContentType = model.content_type;
            res.PublishTime = model.publish_time;

            //if (res.CircleId > 0)
            //{
            //    if (this.request.Images != null && this.request.Images.Count > 0)
            //    {
            //        List<t_circle_image> imgModels = new List<t_circle_image>();
            //        this.request.Images.ForEach((i) =>
            //        {
            //            if (string.IsNullOrEmpty(i.Url)) return;
            //            imgModels.Add(new t_circle_image()
            //            {
            //                circle_id = model.id,
            //                user_id = model.user_id,
            //                image_url = i.Url,
            //                height = i.Height,
            //                width = i.Width
            //            });
            //        });

            //        if (imgModels == null || imgModels.Count <= 0) return res;

            //        try
            //        {
            //            db.t_circle_image.AddRange(imgModels);
            //            db.SaveChanges();
            //        }
            //        catch (Exception)
            //        {
            //        }
            //    }
            //}
            return(res);
        }