public NoveltyDto GetNoveltyById(long Id) { var result = db.Novelties.Where(x => x.IsActive == true & x.Id == Id).Select(y => new NoveltyDto() { Id = y.Id, Title = y.Title, Description = y.Description, IsEnabled = y.IsEnabled, NoveltyTypeId = y.NoveltyTypeId, NoveltyType = y.NoveltyType.Description, Img = y.Img, ImgPath = y.ImgPath, ContenTypeShort = y.ContenTypeShort, ContenTypeLong = y.ContenTypeLong, StartDate = y.StartDate, EndDate = y.EndDate, IsPublic = y.IsPublic, IsActive = y.IsActive, IsDeleted = y.IsDeleted, CreationTime = y.CreationTime, CreatorUserId = y.CreatorUserId, LastModificationTime = y.LastModificationTime, LastModifierUserId = y.LastModifierUserId, DeletionTime = y.DeletionTime, DeleterUserId = y.DeleterUserId, }).FirstOrDefault(); result.Img = string.Concat(result.ContenTypeLong, ',', JS_File.GetStrigBase64(result.ImgPath)); return(result); }
public IHttpActionResult GetNovelties(string noveltyType) { bool isVisitorUser = db.Users.Where(x => x.Id == currentUserId).Select(y => y.IsVisitorUser).FirstOrDefault(); var novelties = new List <NoveltiesByTypeDto>(); var result = new List <NoveltiesByTypeDto>(); if (isVisitorUser) { novelties = db.Novelties.Where(x => x.IsPublic == true && x.IsEnabled == true && x.IsPublic == true && x.IsActive == true && x.NoveltyType.ShortName == noveltyType).Select(y => new NoveltiesByTypeDto() { Id = y.Id, Title = y.Title, Description = y.Description, ImgPath = y.ImgPath, ContenTypeShort = y.ContenTypeShort, ContenTypeLong = y.ContenTypeLong, }).OrderByDescending(x => x.Id).ToList(); } else { novelties = db.Novelties.Where(x => x.IsEnabled == true && x.IsActive == true && x.NoveltyType.ShortName == noveltyType).Select(y => new NoveltiesByTypeDto() { Id = y.Id, Title = y.Title, Description = y.Description, ImgPath = y.ImgPath, ContenTypeShort = y.ContenTypeShort, ContenTypeLong = y.ContenTypeLong, }).OrderByDescending(x => x.Id).ToList(); } foreach (var item in novelties) { item.ImgBase64 = string.Concat(item.ContenTypeLong, ',', JS_File.GetStrigBase64(item.ImgPath)); result.Add(item); } return(Ok(result)); }