public async Task <ImageModel> UploadCoverPhoto() { if (!Request.Content.IsMimeMultipartContent()) { return(null); } var currentProfile = this.ANDBUnitOfWork.UserProfileRepository.GetAll().FirstOrDefault(x => x.UserId.HasValue && x.UserId.Value == CurrentUser.Id); if (currentProfile == null) { return(null); } var filesReadToProvider = await Request.Content.ReadAsMultipartAsync(); if (filesReadToProvider.Contents.Count == 0) { return(null); } var stream = await filesReadToProvider.Contents[0].ReadAsStreamAsync(); var fileKey = string.Format("event/cover/cv{0}.png", Guid.NewGuid().ToString()); var image = await this.CreateNewImage(stream, fileKey); return(ImageMapper.ToModel(image)); }
private IEnumerable <BoardMember> GetBoardMembers() { var members = CurrentPage.Children.Where(x => x.IsDocumentType("BoardMember")); List <BoardMember> lstMembers = new List <BoardMember>(); foreach (var member in members) { var image = member.GetPropertyValue <string>("image"); IPublishedContent imgObj = null; if (image != null) { imgObj = Umbraco.TypedMedia(image); } BoardMember m = new BoardMember() { photo = imgObj != null?ImageMapper.Map <Image>(imgObj) : null, Name = member.GetPropertyValue <string>("name"), Title = member.GetPropertyValue <string>("memberTitle"), ExtraInfo = member.GetPropertyValue <string>("extraInfo"), Email = member.GetPropertyValue <string>("email") }; lstMembers.Add(m); } if (lstMembers.Any()) { return(lstMembers); } return(null); }
public ANEventDetailRequestToJoinModel GetEventDetailRequestToJoin(int Id) { if (!this.ANDBUnitOfWork.ANEventRepository.GetAll().Any(x => x.Id == Id && x.UserId.HasValue && x.UserId.Value == this.CurrentUser.Id)) { throw new HttpResponseException(HttpStatusCode.Forbidden); } var requestEntity = this.ANDBUnitOfWork.ANEventRequestToJoinRepository.GetAll() .Include("User.UserProfiles.Image") .Where(x => x.ANEventId.HasValue && x.ANEventId.Value == Id && x.Status.HasValue && x.Status.Value == (int)Common.ANRequestToJoinStatus.Waiting).ToList(); var RTJmodels = requestEntity.Select(x => { var firstUserProfile = x.User.UserProfiles.FirstOrDefault(); var anEventRTJModel = ANEventRequestToJoinMapper.ToModel(x); anEventRTJModel.User = UserMapper.ToModel(x.User); if (anEventRTJModel.User != null) { anEventRTJModel.User.Profile = UserProfileMapper.ToModel(firstUserProfile); if (anEventRTJModel.User.Profile != null) { anEventRTJModel.User.Profile.Avatar = ImageMapper.ToModel(firstUserProfile.Image); } } return(anEventRTJModel); }).ToList(); return(new ANEventDetailRequestToJoinModel() { EventId = Id, ANEventRequestToJoins = RTJmodels }); }
private List <Album> AlbumArtist(string id) { var responseService = _artistService.AlbumsArtist(id); var arrAlbums = responseService.items; List <Album> listAlbums = new List <Album>(); for (int i = 0; i < arrAlbums.Length; i++) { var tr = new AlbumBusiness(); //Track[] tracksAlbum = tr.Album(arrAlbums[i].id).tracks; Album album = new Album() { name = arrAlbums[i].name, albumArtist = arrAlbums[i].artists[0].name, id = arrAlbums[i].id, images = ImageMapper.ImageMapping(arrAlbums[i].images), totalTracks = arrAlbums[i].total_tracks, type = arrAlbums[i].type, //tracks = tracksAlbum }; listAlbums.Add(album); } return(listAlbums); }
public List <Artist> SearchArtist(string name, SearchEnum type) { var responseService = _searchService.Search(name, type.ToString()); var arrItem = ((ArtistSearch)responseService).artists.items; List <Artist> listArtista = new List <Artist>(); for (int i = 0; i < arrItem.Length; i++) { var alb = new ArtistBusiness(); Artist artist = new Artist() { name = arrItem[i].name, id = arrItem[i].id, type = arrItem[i].type, genres = arrItem[i].genres, popularity = arrItem[i].popularity, images = ImageMapper.ImageMapping(arrItem[i].images) }; listArtista.Add(artist); } return(listArtista); }
public List <Album> SearchAlbum(string name, SearchEnum type) { var responseService = _searchService.Search(name, type.ToString()); var arrItem = ((AlbumSearch)responseService).albums.items; List <Album> listAlbum = new List <Album>(); for (int i = 0; i < arrItem.Length; i++) { var tr = new AlbumBusiness(); Album album = new Album() { name = arrItem[i].name, id = arrItem[i].id, type = arrItem[i].album_type, totalTracks = arrItem[i].total_tracks, albumArtist = arrItem[i].artists[0].name, images = ImageMapper.ImageMapping(arrItem[i].images) }; listAlbum.Add(album); } return(listAlbum); }
public List <Track> SearchTrack(string name, SearchEnum type) { var responseService = _searchService.Search(name, type.ToString()); var arrItem = ((TrackSearch)responseService).tracks.items; List <Track> listTrack = new List <Track>(); for (int i = 0; i < arrItem.Length; i++) { var trackFeatures = _searchService.TrackFeatures(arrItem[i].id); Track track = new Track() { name = arrItem[i].name, id = arrItem[i].id, trackLength = arrItem[i].duration_ms, albumName = arrItem[i].album.name, artistName = arrItem[i].artists[0].name, previewUrl = arrItem[i].preview_url, favorite = false, type = arrItem[i].type, images = ImageMapper.ImageMapping(arrItem[i].album.images), }; track.TrackMapping(trackFeatures); listTrack.Add(track); } return(listTrack); }
public ANEventDetailMemberModel GetEventDetailMember(int Id) { //Thread.Sleep(1000); var entity = this.ANDBUnitOfWork.ANEventRepository.GetAll() .Include("ANEventMembers.User.UserProfiles.Image") .FirstOrDefault(x => x.Id == Id); if (entity == null) { return(null); } var listMember = entity.ANEventMembers.Select(x => { var firstUserProfile = x.User.UserProfiles.FirstOrDefault(); var anEventMemberModel = ANEventMemberMapper.ToModel(x); anEventMemberModel.User = UserMapper.ToModel(x.User); if (anEventMemberModel.User != null) { anEventMemberModel.User.Profile = UserProfileMapper.ToModel(firstUserProfile); if (anEventMemberModel.User.Profile != null) { anEventMemberModel.User.Profile.Avatar = ImageMapper.ToModel(firstUserProfile.Image); } } return(anEventMemberModel); } ).ToList(); return(new ANEventDetailMemberModel() { EventId = entity.Id, ANEventMembers = listMember }); }
public ANEventDetailHeaderModel GetEventDetailHeader(int Id) { var entity = this.ANDBUnitOfWork.ANEventRepository.GetAll() .Include("ANEventInformations") .Include("ANEventImages.Image") .FirstOrDefault(x => x.Id == Id); if (entity == null) { return(null); } var firstInformation = entity.ANEventInformations.FirstOrDefault(); var coverPhoto = entity.ANEventImages.FirstOrDefault(x => x.ANEventImageType == (int)Common.ANEventImageType.ANEventCoverImage); var isPendingMember = this.ANDBUnitOfWork.ANEventRequestToJoinRepository.GetAll().Any(x => x.ANEventId.HasValue && x.ANEventId.Value == Id && x.UserId.HasValue && x.UserId.Value == this.CurrentUser.Id && x.Status == (int)Common.ANRequestToJoinStatus.Waiting); var isMember = this.ANDBUnitOfWork.ANEventMemberRepository.GetAll().Any(x => x.ANEventId.HasValue && x.ANEventId.Value == Id && x.UserId.HasValue && x.UserId.Value == this.CurrentUser.Id); return(new ANEventDetailHeaderModel() { EventID = entity.Id, EventTitle = firstInformation.Title, EventCoverPhoto = ImageMapper.ToModel(coverPhoto != null ? coverPhoto.Image : null), IsHost = entity.UserId.HasValue && this.CurrentUser.Id == entity.UserId.Value, IsPendingMember = isPendingMember, IsMember = isMember }); }
public static Bitmap Decode(EncodedImage encodedImage) { var inversePredictionAlgorithm = new InversePredictionAlgorithm(encodedImage); var decodedImage = inversePredictionAlgorithm.GetDecodedImage(); return(ImageMapper.GetImageFromPixelMatrix(decodedImage.Decoded)); }
public static EncodedImage Encode(Bitmap image, PredictorSettings predictorSettings) { var originalImageMatrix = ImageMapper.GetPixelMatrixFromImage(image); var predictionAlgorithm = new PredictionAlgorithm(originalImageMatrix, predictorSettings); return(predictionAlgorithm.GetEncodedImage()); }
public void SaveImage(Bitmap image, string headerFilePath, string outputPath) { InitializeBitWriter(outputPath); ImageHeaderHandler.CopyHeaderFromFile(headerFilePath, bitWriter); var pixelMatrix = ImageMapper.GetPixelMatrixFromImage(image); WritePixelMatrix(pixelMatrix); }
public IEnumerable <ImageView> Get() { using (DbContext db = DbFactory.Create()) { foreach (Image image in db.Set <Image>()) { yield return(ImageMapper.Map(image)); } } }
public async Task <ImageApplication> GetAsync(string id) { var entity = await _imageRepository.GetAsync(id); if (entity == null) { return(null); } return(ImageMapper.Map(entity)); }
public void Add(ImageView image) { Image dbImage = ImageMapper.Map(image); using (DbContext db = DbFactory.Create()) { // It is better to make generic base class db.Set <Image>().Add(dbImage); db.SaveChanges(); } }
public List <ANEventModel> GetJoinedEvent() { var hostId = this.CurrentUser.Id; var events = this.ANDBUnitOfWork.ANEventRepository.GetAll() .Include(x => x.User) .Include(x => x.User.UserProfiles) .Include("User.UserProfiles.Image") .Include(x => x.ANEventImages) .Include("ANEventImages.Image") .Include("ANEventInformations.ANEventLocation") .Include(x => x.ANEventMembers) .Where(e => e.ANEventMembers.Select(f => f.UserId).Contains(hostId)).OrderByDescending(t => t.CreatedDate).ToList(); var anEventModels = new List <ANEventModel>(); foreach (var ev in events) { var model = new ANEventModel(); model.Id = ev.Id; model.Host = UserMapper.ToModel(ev.User); // get cover image var coverImageEntity = ev.ANEventImages.Where(x => x.ANEventImageType == (int)Common.ANEventImageType.ANEventCoverImage).OrderBy(x => x.SortPriority).FirstOrDefault(); if (coverImageEntity != null) { model.CoverPhoto = ImageMapper.ToModel(coverImageEntity.Image); } var information = ev.ANEventInformations.FirstOrDefault(); model.Information = ANEventInformationMapper.ToModel(information); if (model.Information != null) { model.Information.ANEventLocation = ANEventLocationMapper.ToModel(information.ANEventLocation); } model.CreatedDate = ev.CreatedDate; model.NumberOfMember = ev.ANEventMembers.Count; anEventModels.Add(model); } var groupEvents = anEventModels.GroupBy(t => t.CreatedDate.Year) .Select(gr => new ANEventGroupModel { Year = gr.Key, EventMonth = gr.GroupBy(m => new { m.CreatedDate.Year, m.CreatedDate.Month }) .Select(grm => new ANEventMonthGroup { Month = grm.Key.Month, Events = grm.ToList() }).ToList() }).ToList(); return(anEventModels); }
public List <ANEventModel> GetEventsInNewFeeds() { var currentUserId = this.CurrentUser.Id; var sandbox = new ANEventSearchingSandbox(this.ANDBUnitOfWork); var results = sandbox.Search(new SearchingSandbox.Model.SearchCriteria() { UserId = currentUserId }); var anEventEntities = this.ANDBUnitOfWork.ANEventRepository.GetAll() .Include("User.UserProfiles.Image") .Include("ANEventImages.Image") .Include("ANEventInformations") .Where(x => results.Contains(x.Id)).ToList() .OrderBy(x => results.IndexOf(x.Id)).ToList(); var favoritedEntities = this.ANDBUnitOfWork.ANEventUserFavouriteRepository.GetAll().Where(x => x.ANEventId.HasValue && results.Contains(x.ANEventId.Value) && x.UserId.HasValue && x.UserId.Value == currentUserId).ToList(); var anEventModels = new List <ANEventModel>(); foreach (var entity in anEventEntities) { var anEventModel = ANEventMapper.ToModel(entity); // get host information if (entity.User != null) { anEventModel.Host = UserMapper.ToModel(entity.User); var firstProfile = entity.User.UserProfiles.FirstOrDefault(); anEventModel.Host.Profile = UserProfileMapper.ToModel(firstProfile); if (anEventModel.Host.Profile != null) { anEventModel.Host.Profile.Avatar = ImageMapper.ToModel(firstProfile.Image); } } // get cover image var coverImageEntity = entity.ANEventImages.Where(x => x.ANEventImageType == (int)Common.ANEventImageType.ANEventCoverImage).OrderBy(x => x.SortPriority).FirstOrDefault(); if (coverImageEntity != null) { anEventModel.CoverPhoto = ImageMapper.ToModel(coverImageEntity.Image); } // get information var information = entity.ANEventInformations.FirstOrDefault(); anEventModel.Information = ANEventInformationMapper.ToModel(information); anEventModel.ANEventUserFavourites = ANEventUserFavouriteMapper.ToModel(favoritedEntities.Where(x => x.ANEventId.HasValue && x.ANEventId.Value == anEventModel.Id)); anEventModels.Add(anEventModel); } return(anEventModels); }
public int AddImage(ImageProductViewModel viewModel) { try { var image = ImageMapper.ConvertImageProductViewModelToImage(viewModel); _imageRepository.Add(image); _imageRepository.Save(); return(image.Id); } catch (Exception ex) { throw ex; } }
private Image GetImage() { string imageId = CurrentPage.GetPropertyValue <string>("image"); if (!string.IsNullOrWhiteSpace(imageId)) { IPublishedContent image = Umbraco.TypedMedia(imageId); if (image != null) { return(ImageMapper.Map <Image>(image)); } } return(null); }
public List <ANEventModel> GetMyEventFavourites() { var currentUserId = this.CurrentUser.Id; var anEventEntities = this.ANDBUnitOfWork.ANEventUserFavouriteRepository.GetAll() .Where(x => x.UserId.HasValue && x.UserId.Value == currentUserId) .Select(x => x.ANEvent) .Include("User.UserProfiles.Image") .Include("ANEventImages.Image") .Include("ANEventInformations.ANEventLocation") .ToList() .OrderByDescending(x => x.CreatedDate).ToList(); var anEventModels = new List <ANEventModel>(); var anEventIds = anEventEntities.Select(x => x.Id).ToList(); var numberOfMembers = this.ANDBUnitOfWork.ANEventRepository.GetAll() .Where(x => anEventIds.Contains(x.Id)) .Select(x => new { Id = x.Id, numberOfMember = x.ANEventMembers.Count() }).ToList(); foreach (var entity in anEventEntities) { var anEventModel = ANEventMapper.ToModel(entity); // get host information if (entity.User != null) { anEventModel.Host = UserMapper.ToModel(entity.User); var firstProfile = entity.User.UserProfiles.FirstOrDefault(); anEventModel.Host.Profile = UserProfileMapper.ToModel(firstProfile); if (anEventModel.Host.Profile != null) { anEventModel.Host.Profile.Avatar = ImageMapper.ToModel(firstProfile.Image); } } // get cover image var coverImageEntity = entity.ANEventImages.Where(x => x.ANEventImageType == (int)Common.ANEventImageType.ANEventCoverImage).OrderBy(x => x.SortPriority).FirstOrDefault(); if (coverImageEntity != null) { anEventModel.CoverPhoto = ImageMapper.ToModel(coverImageEntity.Image); } // get information var information = entity.ANEventInformations.FirstOrDefault(); anEventModel.Information = ANEventInformationMapper.ToModel(information); anEventModel.NumberOfMember = numberOfMembers.Where(x => x.Id == anEventModel.Id).Select(x => x.numberOfMember).FirstOrDefault(); anEventModel.Information.ANEventLocation = ANEventLocationMapper.ToModel(information.ANEventLocation); anEventModels.Add(anEventModel); } return(anEventModels); }
public List <ANEventModel> GetEventInWeek() { DateTime input = DateTime.Now; int delta = DayOfWeek.Monday - input.DayOfWeek; int first = input.AddDays(delta).Day; int last = first + 7; var hostId = this.CurrentUser.Id; var events = this.ANDBUnitOfWork.ANEventRepository.GetAll() .Include(x => x.User) .Include(x => x.User.UserProfiles) .Include("User.UserProfiles.Image") .Include(x => x.ANEventImages) .Include("ANEventImages.Image") .Include("ANEventInformations.ANEventLocation") .Include(x => x.ANEventMembers) .Where(e => (e.UserId == (hostId) || e.ANEventMembers.Select(f => f.UserId).Contains(hostId)) && e.ANEventInformations.FirstOrDefault().StartDate.Value.Day >= first && e.ANEventInformations.FirstOrDefault().StartDate.Value.Day < last) .OrderByDescending(t => t.CreatedDate).ToList(); var anEventModels = new List <ANEventModel>(); foreach (var ev in events) { var model = new ANEventModel(); model.Id = ev.Id; model.Host = UserMapper.ToModel(ev.User); // get cover image var coverImageEntity = ev.ANEventImages.Where(x => x.ANEventImageType == (int)Common.ANEventImageType.ANEventCoverImage).OrderBy(x => x.SortPriority).FirstOrDefault(); if (coverImageEntity != null) { model.CoverPhoto = ImageMapper.ToModel(coverImageEntity.Image); } var information = ev.ANEventInformations.FirstOrDefault(); model.Information = ANEventInformationMapper.ToModel(information); if (model.Information != null) { model.Information.ANEventLocation = ANEventLocationMapper.ToModel(information.ANEventLocation); } model.CreatedDate = ev.CreatedDate; model.NumberOfMember = ev.ANEventMembers.Count; anEventModels.Add(model); } return(anEventModels); }
public Album Album(string id) { var responseService = _albumService.Album(id); Album album = new Album() { albumArtist = responseService.artists[0].name, id = responseService.id, images = ImageMapper.ImageMapping(responseService.images), name = responseService.name, totalTracks = responseService.total_tracks, type = responseService.type, tracks = AlbumTracks(id, responseService.name).ToArray() }; return(album); }
/// <summary> /// Get all image record /// </summary> /// <returns></returns> public IEnumerable <Images> GetAllImages() { using (var command = new SqlCommand("GetAllImages", _connection)) { command.CommandType = CommandType.StoredProcedure; var imageList = new List <Images>(); using (var reader = command.ExecuteReader()) { while (reader.Read()) { var image = ImageMapper.Map(reader); imageList.Add(image); } } return(imageList); } }
public async Task SendResultsAsync(ITurnContext context, DocumentSearchResult results) { IMessageActivity activity = context.Activity.CreateReply(); if (results.Results.Count == 0) { await SearchResponses.ReplyWithNoResults(context, facet); } else { SearchHitStyler searchHitStyler = new SearchHitStyler(); searchHitStyler.Apply( ref activity, "Here are the results that I found:", results.Results.Select(r => ImageMapper.ToSearchHit(r)).ToList().AsReadOnly()); await context.SendActivity(activity); } }
public Artist artist(string id) { var responseService = _artistService.Artist(id); Artist artist = new Artist() { name = responseService.name, id = responseService.id, type = responseService.type, genres = responseService.genres, popularity = responseService.popularity, images = ImageMapper.ImageMapping(responseService.images), topTracks = TopTracks(id).ToArray(), albums = AlbumArtist(id).ToArray(), }; return(artist); }
public List <ANEventModel> GetRelatedEvents(int eventId) { var hostId = this.ANDBUnitOfWork.ANEventRepository.GetAll().Where(x => x.Id == eventId).Select(x => x.UserId).FirstOrDefault().GetValueOrDefault(); if (hostId == 0) { return(null); } var events = this.ANDBUnitOfWork.ANEventRepository.GetAll() .Include(x => x.User) .Include(x => x.User.UserProfiles) .Include("User.UserProfiles.Image") .Include(x => x.ANEventImages) .Include("ANEventImages.Image") .Include("ANEventInformations.ANEventLocation") .Include(x => x.ANEventMembers) .Where(e => e.UserId.HasValue && e.UserId.Value == hostId && e.Id != eventId).OrderByDescending(t => t.CreatedDate).Take(3).ToList(); var anEventModels = new List <ANEventModel>(); foreach (var ev in events) { var model = new ANEventModel(); model.Id = ev.Id; model.Host = UserMapper.ToModel(ev.User); // get cover image var coverImageEntity = ev.ANEventImages.Where(x => x.ANEventImageType == (int)Common.ANEventImageType.ANEventCoverImage).OrderBy(x => x.SortPriority).FirstOrDefault(); if (coverImageEntity != null) { model.CoverPhoto = ImageMapper.ToModel(coverImageEntity.Image); } var information = ev.ANEventInformations.FirstOrDefault(); model.Information = ANEventInformationMapper.ToModel(information); if (model.Information != null) { model.Information.ANEventLocation = ANEventLocationMapper.ToModel(information.ANEventLocation); } model.CreatedDate = ev.CreatedDate; model.NumberOfMember = ev.ANEventMembers.Count; anEventModels.Add(model); } return(anEventModels); }
public ANEventDetailInformationModel GetEventDetailInformation(int Id) { //Thread.Sleep(3000); var entity = this.ANDBUnitOfWork.ANEventRepository.GetAll() .Include("ANEventInformations.ANEventLocation") .Include("User.UserProfiles.Image") .FirstOrDefault(x => x.Id == Id); if (entity == null) { return(null); } var firstInformation = entity.ANEventInformations.FirstOrDefault(); var firstUserProfile = entity.User.UserProfiles.FirstOrDefault(); var host = UserMapper.ToModel(entity.User); if (host != null) { if (firstUserProfile != null) { host.Profile = UserProfileMapper.ToModel(firstUserProfile); } if (firstUserProfile.Image != null) { host.Profile.Avatar = ImageMapper.ToModel(firstUserProfile.Image); } } var informationModel = new ANEventDetailInformationModel() { EventID = entity.Id, EventInformation = firstInformation != null? ANEventInformationMapper.ToModel(firstInformation) : null, Host = host }; if (informationModel.EventInformation != null) { informationModel.EventInformation.ANEventLocation = ANEventLocationMapper.ToModel(firstInformation.ANEventLocation); } return(informationModel); }
private async Task SendResultsAsync(ITurnContext context, string searchText, DocumentSearchResult results) { IMessageActivity activity = context.Activity.CreateReply(); if (!results.Results.Any()) { await SearchResponses.ReplyWithNoResults(context, searchText); } else { SearchHitStyler searchHitStyler = new SearchHitStyler(); searchHitStyler.Apply(ref activity, "Here are the results that i found", results.Results.Select(r => ImageMapper.ToSearchHit(r)).ToList().AsReadOnly()); await context.SendActivityAsync(activity); } }
public FullEventViewModel MapFull(Event src) { return(new FullEventViewModel { Id = src.Id, State = src.State.ToString(), Created = src.Created, LastModified = src.Modified, Name = src.Name, AllDay = src.AllDay, Start = src.Start, End = src.End, Attendance = src.Attendance.Select(a => AttendanceMapper.Map(a)), Reports = src.Reports.Select(r => ReportMapper.Map(r)), Images = src.Images.Select(i => ImageMapper.Map(i)), }); }
public async Task SendResultsAsync(ITurnContext context, string searchText, DocumentSearchResult results) { IMessageActivity activity = context.Activity.CreateReply(); // if the search returns no results if (results.Results.Count == 0) { await SearchResponses.ReplyWithNoResults(context, searchText); } else // this means there was at least one hit for the search { // create the response with the result(s) and send to the user SearchHitStyler searchHitStyler = new SearchHitStyler(); searchHitStyler.Apply( ref activity, "Here are the results that I found:", results.Results.Select(r => ImageMapper.ToSearchHit(r)).ToList().AsReadOnly()); await context.SendActivityAsync(activity); } }