Пример #1
0
        public void ProcessRequest(HttpContext context)
        {
            Guid pid = Guid.Empty;

            if (!string.IsNullOrEmpty(context.Request["pid"]))
            {
                pid = new Guid(context.Request["pid"]);
            }
            string isshow = string.Empty;

            if (!string.IsNullOrEmpty(context.Request["isshow"]))
            {
                isshow = context.Request["isshow"];
            }
            //isshare
            string isshare = string.Empty;

            if (!string.IsNullOrEmpty(context.Request["isshare"]))
            {
                isshare = context.Request["isshare"];
            }
            UCHomeEntities uc    = new UCHomeEntities();
            UCHome_Album   album = uc.UCHome_Album.SingleOrDefault(n => n.PKID == pid);

            if (album != null)
            {
                if (!string.IsNullOrEmpty(isshow) && uc.UCHome_Rel_AblumPhoto.Any(u => u.AlbumID == pid))
                {
                    context.Response.ContentType = "text/plain";
                    context.Response.Write("201");
                    context.Response.End();
                }
                else
                {
                    if (!string.IsNullOrEmpty(isshow))
                    {
                        album.IsShow = int.Parse(isshow);
                    }
                    if (!string.IsNullOrEmpty(isshare))
                    {
                        album.IsShare = isshare;
                    }
                    uc.SaveChanges();
                    context.Response.ContentType = "text/plain";
                    context.Response.Write("200");
                }
            }
            else
            {
                context.Response.ContentType = "text/plain";
                context.Response.Write("202");
            }
        }
Пример #2
0
        public void ProcessRequest(HttpContext context)
        {
            Guid pid = Guid.Empty;

            if (!string.IsNullOrEmpty(context.Request["pid"]))
            {
                pid = new Guid(context.Request["pid"]);
            }
            string isshow = string.Empty;

            if (!string.IsNullOrEmpty(context.Request["isshow"]))
            {
                isshow = context.Request["isshow"];
            }
            UCHomeEntities uc    = new UCHomeEntities();
            UCHome_Photo   photo = uc.UCHome_Photo.SingleOrDefault(n => n.PKID == pid);

            if (photo != null)
            {
                if (!string.IsNullOrEmpty(isshow))
                {
                    photo.IsShow = int.Parse(isshow);
                }
                uc.SaveChanges();
                List <UCHome_Rel_AblumPhoto> relAblumPhotos = uc.UCHome_Rel_AblumPhoto.Where(r => r.PhotoID == pid).ToList();
                List <Guid>         pkids  = relAblumPhotos.Select(a => a.AlbumID).Distinct().ToList();
                List <UCHome_Album> albums = uc.UCHome_Album.Where(a => pkids.Contains(a.PKID)).ToList();
                foreach (UCHome_Rel_AblumPhoto ucHomeRelAblumPhoto in relAblumPhotos)
                {
                    if (ucHomeRelAblumPhoto.IsCover == 1)
                    {
                        UCHome_Album album = albums.SingleOrDefault(a => a.PKID == ucHomeRelAblumPhoto.AlbumID);
                        if (album != null)
                        {
                            album.CoverImg = "";
                            uc.SaveChanges();
                        }
                    }
                    uc.DeleteObject(ucHomeRelAblumPhoto);
                    uc.SaveChanges();
                }
                context.Response.ContentType = "text/plain";
                context.Response.Write("200");
            }
            else
            {
                context.Response.ContentType = "text/plain";
                context.Response.Write("202");
            }
        }
Пример #3
0
        public void ProcessRequest(HttpContext context)
        {
            Guid pid = Guid.Empty;

            if (!string.IsNullOrEmpty(context.Request["pid"]))
            {
                pid = new Guid(context.Request["pid"]);
            }
            UCHomeEntities uc    = new UCHomeEntities();
            UCHome_Photo   photo = uc.UCHome_Photo.SingleOrDefault(n => n.PKID == pid);

            if (photo != null)
            {
                string purl = photo.PhotoUrl;
                photo.IsAblumCover = "1";
                uc.SaveChanges();
                UCHome_Rel_AblumPhoto relAblumPhoto = uc.UCHome_Rel_AblumPhoto.FirstOrDefault(r => r.PhotoID == pid);
                if (relAblumPhoto != null)
                {
                    Guid albumid = relAblumPhoto.AlbumID;
                    relAblumPhoto.IsCover = 1;
                    UCHome_Album album = uc.UCHome_Album.SingleOrDefault(p => p.PKID == albumid);
                    if (album != null)
                    {
                        album.CoverImg = purl;
                        uc.SaveChanges();
                        context.Response.ContentType = "text/plain";
                        context.Response.Write("200");
                    }
                    else
                    {
                        context.Response.ContentType = "text/plain";
                        context.Response.Write("201");
                    }
                }
                else
                {
                    context.Response.ContentType = "text/plain";
                    context.Response.Write("201");
                }
            }
            else
            {
                context.Response.ContentType = "text/plain";
                context.Response.Write("202");
            }
        }
Пример #4
0
        public ActionResult AddAlbum(FormCollection form)
        {
            string       opertype = form["opertype"];
            UCHome_Album album    = new UCHome_Album();

            if (opertype == "add")
            {
                album.PKID          = Guid.NewGuid();
                album.AlbumName     = form["album-name"];
                album.AlbumAbstract = form["album-memo"];
                album.AlbumThemes   = form["album-themes"];
                album.AlbumType     = form["album-type"];
                album.IsShare       = form["album-role"];
                album.AddUser       = new Guid(form["AddUser"]);
                album.CreateTime    = DateTime.Now;
                album.IsShow        = 1;
                uc.UCHome_Album.AddObject(album);
            }
            else
            {
                Guid pkid = new Guid(form["PKID"]);
                album = uc.UCHome_Album.SingleOrDefault(a => a.PKID == pkid);
                if (album != null)
                {
                    album.AlbumName     = form["album-name"];
                    album.AlbumAbstract = form["album-memo"];
                    album.AlbumThemes   = form["album-themes"];
                    album.AlbumType     = form["album-type"];
                    album.IsShare       = form["album-role"];
                }
            }
            try
            {
                uc.SaveChanges();
                return(Json(true, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
Пример #5
0
        public ActionResult PhotoShowByAlbum2(Guid albumid)
        {
            UCHome_Album album = uc.UCHome_Album.SingleOrDefault(a => a.PKID == albumid);

            return(PartialView("PhotoShowByAlbum2", album));
        }