Example #1
0
        public static void Configure(AutoMapper.IConfiguration configuration)
        {
            configuration.CreateMap <Project, ProjectTableRowModel>()
            .ForMember(x => x.AllAssessments, y => y.ResolveUsing(x => x.Assessments.Count()))
            .ForMember(x => x.ConfirmedAssessments, y => y.ResolveUsing(x => x.Assessments.Where(ass => ass.Confirmed).Count()));
            configuration.CreateMap <AddProjectViewModel, Project>()
            .ForMember(destination => destination.Experts, destination => destination.Ignore());
            configuration.CreateMap <Project, AddProjectViewModel>()
            .ForMember(destination => destination.Users, destination => destination.ResolveUsing(source => source.Experts.Select(x => x.UserId).ToArray()));

            configuration.CreateMap <AlternativeModel, Alternative>()
            .ForMember(destinationMember => destinationMember.AlternativeName, destination => destination.ResolveUsing(source => source.Name));
            configuration.CreateMap <FactorModel, Factor>()
            .ForMember(destinationMember => destinationMember.FactorName, destination => destination.ResolveUsing(source => source.Name));

            configuration.CreateMap <Alternative, AlternativeModel>()
            .ForMember(destinationMember => destinationMember.Name, destination => destination.ResolveUsing(source => source.AlternativeName));
            configuration.CreateMap <Factor, FactorModel>()
            .ForMember(destinationMember => destinationMember.Name, destination => destination.ResolveUsing(source => source.FactorName));

            configuration.CreateMap <ExpertAssessment, AssessmentTableRowModel>()
            .ForMember(destination => destination.ProjectName, destination => destination.ResolveUsing(source => source.Project.Name));

            configuration.CreateMap <ExpertAssessment, AssessmentDetailsViewModel>();
        }
Example #2
0
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap <TituloConsignacionRendidasDetalle, TituloConsignacionRendidasDetalleDto>()
     .ForMember(d => d.TituloNombre, opt => { opt.MapFrom(s => s.Titulo.NombreTitulo); })
     .ForMember(d => d.TituloCodigo, opt => { opt.MapFrom(s => s.Titulo.Cod); })
     .ForMember(d => d.TituloAutor, opt => { opt.MapFrom(s => s.Titulo.Autor.Nombre); });
 }
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap<Ticket, TicketDetailsViewModel>()
         .ForMember(m => m.CategoryName, opt => opt.MapFrom(t => t.Category.Name))
         .ForMember(m => m.AuthorName, opt => opt.MapFrom(t => t.Author.UserName))
         .ReverseMap();
 }
Example #4
0
 public override void DefineMap(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap <InputModel, Deployment>()
     .ForMember(a => a.CreateDate, b => b.Ignore())
     .ForMember(a => a.LastModifyDate, b => b.Ignore())
     ;
 }
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap <Post, IndexBlogPostViewModel>()
     .ForMember(
         t => t.VoteValues,
         o => o.MapFrom(b => b.Votes.Count() == 0 ? 0 : b.Votes.Select(v => v.VoteValue).Sum()));
 }
Example #6
0
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap <Taxi, TaxiDTO>()
     .ForMember(dm =>
                dm.Status,
                opt => opt.MapFrom(m => (int)m.Status));
 }
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap <Post, PostViewModel>()
     .ForMember(
         t => t.AuthorName,
         o => o.MapFrom(b => b.Author.UserName));
 }
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap <Faculty, FacultyProfileViewModel>()
     .ForMember(f => f.StudentsNumber, opt => opt.MapFrom(f => f.Specialties.Sum(s => s.Students.Count)))
     .ForMember(f => f.ThesisCompleteNummber, opt => opt.MapFrom(f => f.Specialties.Sum(st => st.Students.Sum(s => s.Theses.Where(t => t.IsComplete).Count()))))
     .ForMember(f => f.ThesisInProressNumber, opt => opt.MapFrom(f => f.Specialties.Sum(st => st.Students.Sum(s => s.Theses.Where(t => !t.IsComplete).Count()))));
 }
Example #9
0
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap <User, UserViewModel>()
     .ForMember(u => u.Id, opt => opt.MapFrom(v => v.Id))
     .ForMember(u => u.UserName, opt => opt.MapFrom(v => v.UserName))
     .ReverseMap();
 }
Example #10
0
 public void CreateMappings(AutoMapper.IConfiguration config)
 {
     config.CreateMap <HomeworkModel, Homework>()
     .ForMember(h => h.TimeSent,
                opts => opts
                .MapFrom(s => DateTime.Now));
 }
Example #11
0
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap <Game, GameResponseSimpleModel>()
     .ForMember(g => g.Red, opts => opts.MapFrom(g => g.RedPlayer.UserName))
     .ForMember(g => g.Blue, opts => opts.MapFrom(g => g.BluePlayer == null ? "No blue player yet" : g.BluePlayer.UserName))
     .ForMember(g => g.GameState, opts => opts.MapFrom(g => g.GameState.ToString()));
 }
Example #12
0
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap <Create, Model.CodeMain>()
     .ForMember(m => m.CreateDate, opt => opt.UseValue(DateTime.Now))
     .ForMember(m => m.CreateBy, opt => opt.UseValue("Admin"));
     // TODO: change to real user once authorisation is done.
 }
        public void CreateMappings(AutoMapper.IConfiguration configuration)
        {
            configuration.CreateMap <Prize, PrizeViewModel>()
            .ForMember(x => x.WinnerId, cnf => cnf.MapFrom(u => u.Id));

            configuration.CreateMap <Prize, PrizeViewModel>()
            .ForMember(x => x.Username, cnf => cnf.MapFrom(u => u.Winner.UserName));
        }
Example #14
0
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap <TagViewModel, string>().ConvertUsing(r => r.Name);
     configuration.CreateMap <string, TagViewModel>().ConvertUsing(s => new TagViewModel()
     {
         Name = s
     });
 }
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap <Thesis, ThesisDetailViewModel>()
     .ForMember(u => u.StudentName, opt => opt.MapFrom(u => u.Student.User.FirstName + " " + u.Student.User.MiddleName + " " + u.Student.User.LastName))
     .ForMember(u => u.SupervisorName, opt => opt.MapFrom(u => u.Supervisor.User.FirstName + " " + u.Supervisor.User.MiddleName + " " + u.Supervisor.User.LastName))
     .ForMember(u => u.Faculty, opt => opt.MapFrom(u => u.Student.Specialty.Faculty.Title))
     .ForMember(u => u.Specialty, opt => opt.MapFrom(u => u.Student.Specialty.Title));
 }
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap <Match, MatchDetailsViewModel>()
     .ForMember(x => x.HomeTeamName, cnf => cnf.MapFrom(u => u.HomeTeam.Name))
     .ForMember(x => x.AwayTeamName, cnf => cnf.MapFrom(u => u.AwayTeam.Name))
     .ForMember(x => x.AwayBet, m => m.MapFrom(y => y.Bets.Any() ? y.Bets.Sum(v => v.AwayBet) : 0))
     .ForMember(x => x.HomeBet, m => m.MapFrom(y => y.Bets.Any() ? y.Bets.Sum(v => v.HomeBet) : 0));
 }
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap <Produto, ProdutoViewModel>()
     .ForMember(m => m.Categoria, opt =>
                opt.MapFrom(u => u.Categoria.NomeCategoria))
     .ForMember(m => m.Ativo, opt =>
                opt.MapFrom(u => u.DtInativacao == null));
 }
Example #18
0
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap <Ticket, ListTicketViewModel>()
     .ForMember(m => m.TicketTitle, opt => opt.MapFrom(t => t.Title))
     .ForMember(m => m.CategoryName, opt => opt.MapFrom(t => t.Category.Name))
     .ForMember(m => m.AuthorUserName, opt => opt.MapFrom(t => t.Author.UserName))
     .ForMember(m => m.Priority, opt => opt.MapFrom(t => t.Priority.ToString()))
     .ReverseMap();
 }
Example #19
0
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap <Pet, PetDetailsViewModel>()
     .ForMember(m => m.OwnerName, opt => opt.MapFrom(t => t.Owner.UserName))
     .ForMember(m => m.SpeciesName, opt => opt.MapFrom(t => t.Species.Name))
     .ForMember(m => m.BreedName, opt => opt.MapFrom(t => t.Breed.Name))
     .ForMember(m => m.ReservationsCount, opt => opt.MapFrom(t => t.Reservations.Count))
     .ReverseMap();
 }
Example #20
0
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap <Profile, ProfileViewModel>()
     .ForMember(m => m.Country, opt => opt.MapFrom(pvm => pvm.Country.ToString()))
     .ForMember(m => m.Status, opt => opt.MapFrom(pvm => pvm.Status.ToString()))
     .ForMember(m => m.Visibility, opt => opt.MapFrom(pvm => pvm.Visibility.ToString()))
     .ForMember(m => m.Language, opt => opt.MapFrom(pvm => pvm.Language.ToString()))
     .ReverseMap();
 }
Example #21
0
        public void CreateMappings(AutoMapper.IConfiguration configuration)
        {
            configuration.CreateMap <Article, ListArticleModel>()
            .ForMember(m => m.ArticleTitle, opt => opt.MapFrom(a => a.Title))
            .ForMember(m => m.CategoryName, opt => opt.MapFrom(c => c.Category.Name))
            .ForMember(m => m.AuthorUserName, opt => opt.MapFrom(u => u.Author.UserName))

            .ReverseMap();
        }
Example #22
0
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap <Ticket, TicketViewModel>()
     .ForMember(m => m.TicketTitle, opt => opt.MapFrom(t => t.Title))
     .ForMember(m => m.CategoryName, opt => opt.MapFrom(t => t.Category.Name))
     .ForMember(m => m.AuthorUserName, opt => opt.MapFrom(t => t.Author.UserName))
     .ForMember(m => m.NumberOfComments, opt => opt.MapFrom(t => t.Comments.Count()))
     .ReverseMap();
 }
Example #23
0
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap <LikeIt.Models.Page, VotesViewModel>()
     .ForMember(m => m.Rating, opt => opt.MapFrom(x => x.Rating))
     .ForMember(m => m.LikesCount, opt => opt.MapFrom(x => x.Likes.Where(l => !l.IsDeleted).Count()))
     .ForMember(m => m.DislikesCount, opt => opt.MapFrom(x => x.Dislikes.Where(l => !l.IsDeleted).Count()))
     .ForMember(m => m.PageId, opt => opt.MapFrom(x => x.Id))
     .ReverseMap();
 }
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap <Thesis, DevThesisIndexViewModel>()
     .ForMember(u => u.StudentName, opt => opt.MapFrom(u => u.Student.User.FirstName + " " + u.Student.User.LastName))
     .ForMember(u => u.SupervisorName, opt => opt.MapFrom(u => u.Supervisor.User.FirstName + " " + u.Supervisor.User.LastName))
     .ForMember(u => u.Oks, opt => opt.MapFrom(u => u.Student.Oks))
     .ForMember(u => u.DaysDeveloping, opt => opt.MapFrom(u => DbFunctions.DiffDays(u.CreatedOn, DateTime.Now)))
     .ForMember(u => u.CompletedPercent, opt => opt.MapFrom(u =>
                                                            u.ThesisParts.Count() == 0 ? 0 : (int)(u.ThesisParts.Where(p => p.Flag == ThesisFlag.Complete).Count() / (double)u.ThesisParts.Count() * 100)));
 }
        public void CreateMappings(AutoMapper.IConfiguration configuration)
        {
            configuration.CreateMap <Produto, ProdutoFormViewModel>()
            .ForMember(m => m.Ativo, opt =>
                       opt.MapFrom(u => u.DtInativacao == null));

            configuration.CreateMap <ProdutoFormViewModel, Produto>()
            .ForMember(m => m.DtInativacao, opt =>
                       opt.MapFrom(u => u.Ativo ? (DateTime?)null : DateTime.Now));
        }
Example #26
0
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap <Google.YouTube.Video, MediaItemViewModel>()
     .ForMember(dst => dst.Id, opt => opt.Ignore())
     .ForMember(dst => dst.VideoId, opt => opt.MapFrom(src => src.VideoId))
     .ForMember(dst => dst.Title, opt => opt.MapFrom(src => src.Title))
     .ForMember(dst => dst.Duration, opt => opt.MapFrom(src => long.Parse(src.Media.Duration.Seconds)))
     .ForMember(dst => dst.MQImageUrl, opt => opt.MapFrom(src => src.Thumbnails[1].Url))
     .ForMember(dst => dst.HQImageUrl, opt => opt.MapFrom(src => src.Thumbnails[2].Url));
 }
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap <Taxi, TaxiDetailsDTO>()
     .ForMember(dm => dm.DistrictId, opt => opt.MapFrom(m => m.District.DistrictId))
     .ForMember(dm => dm.DriverName, opt => opt.MapFrom(m => m.Driver.FirstName + " " + m.Driver.LastName))
     .ForMember(dm => dm.Phone, opt => opt.MapFrom(m => m.Driver.PhoneNumber))
     .ForMember(dm => dm.TaxiStandId, opt => opt.MapFrom(m => m.TaxiStand != null ? m.TaxiStand.TaxiStandId : -1))
     .ForMember(dm => dm.TaxiStandAlias, opt => opt.MapFrom(m => m.TaxiStand != null ? m.TaxiStand.Alias : "new"))
     .ForMember(dm => dm.Status, opt => opt.MapFrom(m => (int)m.Status));
 }
Example #28
0
        public virtual void CreateMappings(AutoMapper.IConfiguration configuration)
        {
            configuration.CreateMap <ApplicationUser, UserVM>()
            .ForMember(m => m.FullName, opt => opt.MapFrom(t => t.FirstName + " " + t.MiddleName + " " + t.LastName))
            .ForMember(m => m.District, opt => opt.MapFrom(t => t.District.Title));

            //configuration.CreateMap<UserVM, ApplicationUser>()
            //    .ForMember(m => m.FirstName, opt => opt.MapFrom(t => t.FullName.Split(' ').FirstOrDefault()))
            //    .ForMember(m => m.MiddleName, opt => opt.MapFrom(r => r.FullName.Split(' ').ElementAtOrDefault(1)))
            //    .ForMember(m => m.LastName, opt => opt.MapFrom(r => r.FullName.Split(' ').LastOrDefault()));
        }
        public void CreateMappings(AutoMapper.IConfiguration configuration)
        {
            configuration.CreateMap <Phone, PhoneViewModel>()
            .ForMember(from => from.PhoneStatus, opt => opt.MapFrom(to => to.PhoneStatus.ToString()));

            configuration.CreateMap <Phone, PhoneViewModel>()
            .ForMember(from => from.CardType, opt => opt.MapFrom(to => to.CardType.ToString()));

            configuration.CreateMap <Phone, PhoneViewModel>()
            .ForMember(from => from.UserName, opt => opt.MapFrom(to => to.User.UserName));
        }
Example #30
0
        public void CreateMappings(AutoMapper.IConfiguration configuration)
        {
            string adminRoleId = string.Empty;

            configuration.CreateMap <User, UserInfoViewModel>()
            .ForMember(d => d.IsAdmin, opt => opt.MapFrom(to => to.Roles.Any(x => x.RoleId == adminRoleId)));

            configuration.CreateMap <UserInfoViewModel, User>()
            .ForMember(d => d.DepartmentId, opt => opt.MapFrom(to => to.DepartmentName));

            configuration.CreateMap <UserInfoViewModel, User>()
            .ForMember(d => d.JobTitleId, opt => opt.MapFrom(to => to.JobTitleName));
        }