public void ProcessRequest(HttpContext context) { Guid id = Guid.Empty; if (!string.IsNullOrEmpty(context.Request.QueryString["pid"])) { id = new Guid(context.Request.QueryString["pid"]); } UCHomeEntities uc = new UCHomeEntities(); UCHome_Photo pn = uc.UCHome_Photo.SingleOrDefault(u => u.PKID == id); if (pn != null) { pn.flowers = pn.flowers + 1; } try { uc.SaveChanges(); context.Response.ContentType = "text/plain"; context.Response.Write(true); } catch (Exception) { context.Response.ContentType = "text/plain"; context.Response.Write(false); } }
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"); } }
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"); } }
public string AddUCHome_Photos(HttpPostedFileBase file, Guid AddUser, string webpath) { UCHome_Photo photo = new UCHome_Photo { PKID = Guid.NewGuid(), PhotoName = file.FileName.Substring(0, file.FileName.LastIndexOf('.')), PhotoAbstract = "", IsAblumCover = "0", AddUser = AddUser, CreateTime = DateTime.Now, Hits = 0, flowers = 0, PhotoUrl = webpath, IsShow = 1 }; uc.UCHome_Photo.AddObject(photo); uc.SaveChanges(); AddSNSFeedEntry feed = new AddSNSFeedEntry { ObjectType = "更新相册", ObjectID = photo.PKID.ToString(), UID = AddUser.ToString(), UName = DisPlayName, School = XXMC, Title = photo.CreateTime + "更新了相册", Summary = webpath, Date = DateTime.Now, //URL = "http://www.baidu.com", Like = 0, Favorite = 0 }; client.Send <AddSNSFeedEntry>(feed); return(photo.PKID.ToString()); }