예제 #1
1
 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.
 }
        /// <summary>
        /// All mapping here should be between any model types and the service layer objects.
        /// </summary>
        /// <param name="mappingConfiguration"></param>
        public static void Configure(AutoMapper.IConfiguration mappingConfiguration)
        {
            //reversible maps for types that pass out of the API and bback in again.
            mappingConfiguration.CreateMap<MyObjectModel, MyObject>().ReverseMap();

            //non-reversible maps for types that are only ever passed out of the API
            mappingConfiguration.CreateMap(typeof(PagedResult<>), typeof(PagedResultModel<>));
        }
예제 #3
0
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     var conf = (AutoMapper.IMapperConfiguration)configuration;
     var defaultMark = new Mark() { Answer = -0.001f };
     conf.CreateMap<Teacher, TeacherViewModel>()
     .ReverseMap();
 }
예제 #4
0
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap<Domain.Entities.Project, Project>()
         .ForMember(dest => dest.SiteDataCount, opt => opt.MapFrom(src => src.Sites.Count))
         .ForMember(dest => dest.FieldDataCount, opt => opt.MapFrom(src => src.Fields.Count))
         .ForMember(dest => dest.SummaryDataCount, opt => opt.MapFrom(src => src.SiteSummaries.Count));
 }
예제 #5
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>();
        }
 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<ChallengeAccepted.Models.User, EditProfileViewModel>()
        .ForMember(m => m.Latitude, opt => opt.MapFrom(x => x.Location.Latitude))
        .ForMember(m => m.Longitude, opt => opt.MapFrom(x => x.Location.Longitude))
        .ReverseMap();
 }
			public void Example()
			{
				var order = new {CustomerName = "Bob Smith"};

				var message = Mapper.DynamicMap<ICreateOrderMessage>(order);

				message.CustomerName.ShouldEqual("Bob Smith");
			}
예제 #9
0
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap<IBuildDefinition, TfsBuildDefViewModel>()
         .ForMember(vm => vm.LastModifiedBy, m => m.MapFrom(bd => bd.Workspace.LastModifiedBy))
         .ForMember(vm => vm.LastModifiedDate, m => m.MapFrom(bd => bd.Workspace.LastModifiedDate))
         .ForMember(vm => vm.WorkspaceMappings, m => m.MapFrom(bd => bd.Workspace.Mappings))
         .ForMember(vm => vm.Enabled, m => m.MapFrom(bd => bd.Enabled));
 }
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap<Domain.Issue, IssueDetailsViewModel>()
         .ForMember(m => m.AssignedToUserName, opt =>
             opt.MapFrom(u => u.AssignedToUser.UserName))
         .ForMember(m => m.CreatorUserName, opt =>
             opt.MapFrom(u => u.CreatedUser.UserName));
 }
 public PermissionController(Conversation.IConversation conversation, AutoMapper.IMappingEngine mapper, Rhino.Security.Mgmt.Data.PermissionRepository repository, Rhino.Security.Mgmt.Infrastructure.IValidator validator, Rhino.Security.Mgmt.Infrastructure.IStringConverter<Rhino.Security.Model.Permission> stringConverter)
 {
     _conversation = conversation;
     _mapper = mapper;
     _repository = repository;
     _validator = validator;
     _stringConverter = stringConverter;
 }
예제 #12
0
 public OrderDetailController(Conversation.IConversation conversation, AutoMapper.IMappingEngine mapper, ExtMvc.Data.OrderDetailRepository repository, Nexida.Infrastructure.IValidator validator, Nexida.Infrastructure.IStringConverter<ExtMvc.Domain.OrderDetail> stringConverter)
 {
     _conversation = conversation;
     _mapper = mapper;
     _repository = repository;
     _validator = validator;
     _stringConverter = stringConverter;
 }
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     Mapper.CreateMap<Domain.ApplicationUser, Models.AssignmentStatsViewModel>()
         .ForMember(m => m.UserName, opt => opt.MapFrom(i => i.UserName))
         .ForMember(m => m.Enhancements, opt => opt.MapFrom(i => i.Assignments.Count(r => r.IssueType == IssueType.Enhancement)))
         .ForMember(m => m.Bugs, opt => opt.MapFrom(i => i.Assignments.Count(r => r.IssueType == IssueType.Bug)))
         .ForMember(m => m.Support, opt => opt.MapFrom(i => i.Assignments.Count(r => r.IssueType == IssueType.Support)))
         .ForMember(m => m.Other, opt => opt.MapFrom(i => i.Assignments.Count(r => r.IssueType == IssueType.Other)));
 }
        /// <summary>
        /// All mapping here should be between any model types and the service layer objects.
        /// </summary>
        /// <param name="mappingConfiguration"></param>
        public static void Configure(AutoMapper.IConfiguration mappingConfiguration)
        {
            //reversible maps for types that pass out of the API and back in again.
            mappingConfiguration.CreateMap<MyObjectModel, MyObject>().ReverseMap();

            //hoping this will work - as we need to map generic paged results of service layer types to
            //paged results of our model types.
            mappingConfiguration.CreateMap(typeof(PagedResult<>), typeof(PagedResult<>));
        }
        public IHttpActionResult Something()
        {
            var obj = new { email = FakeO.Internet.Email() };

            var context = NotificationHub.GetHubContext();

            context.Clients.All.ping(obj);

            return Ok(new ApiResponse(200, obj));
        }
예제 #16
0
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap<BranchObject, TfsBranchViewModel>()
         .ForMember(vm => vm.Project, m => m.MapFrom(bo => bo.Properties.RootItem.Item.Substring(0, bo.Properties.RootItem.Item.IndexOf('/', 2))))
         .ForMember(vm => vm.IsDeleted, m => m.MapFrom(bo => bo.Properties.RootItem.IsDeleted))
         .ForMember(vm => vm.Branch, m => m.MapFrom(bo => bo.Properties.RootItem.Item.Replace(bo.Properties.RootItem.Item.Substring(0, bo.Properties.RootItem.Item.IndexOf('/', 2)), "")))
         .ForMember(vm => vm.Version, m => m.MapFrom(bo => (bo.Properties.RootItem.Version as ChangesetVersionSpec).ChangesetId))
         .ForMember(vm => vm.Owner, m => m.MapFrom(bo => bo.Properties.Owner))
         .ForMember(vm => vm.Parent, m => m.MapFrom(bo => bo.Properties.ParentBranch != null ? bo.Properties.ParentBranch.Item.Replace(bo.Properties.RootItem.Item.Substring(0, bo.Properties.RootItem.Item.IndexOf('/', 2)), "") : ""));
 }
        public void Should_Create_Maps_Via_Map_Creators()
        {
            // arrange
            var configurationProvider = new Mock<IConfigurationProvider>();
            var profileExpression = new Mock<IProfileExpression>();
            var mapCreator = new Mock<IMapCreator>();
            var mapCreators = new[] { mapCreator.Object, mapCreator.Object };

            // act
            new AutoMapperConfigurationStartupTask(configurationProvider.Object, profileExpression.Object, mapCreators).Execute();

            // assert
            mapCreator.Verify(creator => creator.CreateMap(profileExpression.Object), Times.Exactly(2));
        }
        public void Should_Assert_Configuration_Is_Valid()
        {
            // arrange
            var configurationProvider = new Mock<IConfigurationProvider>();
            var profileExpression = new Mock<IProfileExpression>();
            var mapCreator = new Mock<IMapCreator>();
            var mapCreators = new[] { mapCreator.Object };

            // act
            new AutoMapperConfigurationStartupTask(configurationProvider.Object, profileExpression.Object, mapCreators).Execute();

            // assert
            configurationProvider.Verify(configProvider => configProvider.AssertConfigurationIsValid());
        }
예제 #19
0
        public void Override_mappings_should_take_affect()
        {
            // Arrange
            var autoMapper = new AutoMapper();
            HbmClass root;

            // Act
            autoMapper.EntityBaseType = typeof (AutoMapperTestEntityBase);
            autoMapper.Override(map => map.Class<Parent>(mapper => mapper.Table("PARENT")));
            autoMapper.MapAssemblyOf<AutoMapperTests>(overrideFilter: type => false);

            root = autoMapper.Complete().First().RootClasses.First(c => c.name == "Parent");

            // Assert
            root.table.Should().Be("PARENT");
        }
예제 #20
0
        public void SetUpFixture()
        {
            var automapper = new AutoMapper
                                 {
                                     EntityBaseType = typeof (AutoMapperTestEntityBase)
                                 };

            automapper.Override(mapper =>
                                    {

                                    });
            automapper.MapAssemblyOf<AutoMapperTests>();

            _mapping = automapper.Complete().First();

            automapper = new AutoMapper
                             {
                                 EntityBaseType = typeof(AutoMapperTestEntityBase<Guid>)
                             };
            automapper.MapAssemblyOf<AutoMapperTests>();
            _guidMapping = automapper.Complete().First();
        }
예제 #21
0
        public void Script()
        {
            var automapper = new AutoMapper
            {
                EntityBaseType = typeof(AutoMapperTestEntityBase)
            };
            automapper.MapAssemblyOf<SchemaTests>();

            var compiled = automapper.Complete();

            var configuration = new Configuration();
            configuration.DataBaseIntegration(db =>
                                                  {
                                                      db.Dialect<SQLiteDialect>();
                                                      db.ConnectionString = "Data Source=:memory:;Version=3;New=True";
                                                  });

            configuration.AddDeserializedMapping(compiled.First(), string.Empty);

            var export = new SchemaExport(configuration);

            export.Execute(true, false, false);
        }
예제 #22
0
        public void DeleteRange_Models()
        {
            IEnumerable<TestModel> models = new[] { ObjectFactory.CreateTestModel(1), ObjectFactory.CreateTestModel(2) };
            foreach (TestModel model in models)
                context.Set<TestModel>().Add(model);

            context.SaveChanges();

            unitOfWork.DeleteRange(models);
            unitOfWork.Commit();

            Assert.Empty(context.Set<TestModel>());
        }
 public IEnumerable <AuthorBook> Get()
 {
     return(AutoMapper <IEnumerable <BUsersBook>, List <AuthorBook> > .Map(userBookService.GetUsersBooks));
 }
예제 #24
0
 public ActionResult Index()
 {
     return(View(AutoMapper <IEnumerable <BOrders>, List <AuthorBook> > .Map(orderService.GetOrders)));
 }
예제 #25
0
        public ActionResult EditAndCreate(int?id = 0)
        {
            AuthorModel author = AutoMapper <BAuthor, AuthorModel> .Map(authorService.GetAuthor, (int)id);

            return(PartialView("EditOrCreate", author));
        }
예제 #26
0
 static Fixture CloneObject(Fixture fixture)
 {
     return(AutoMapper.Map <Fixture, Fixture>(fixture));
 }
예제 #27
0
        public async Task <OutputHandler> UpdateQoute(QouteDTO qouteDTO)
        {
            try
            {
                if (qouteDTO.ImgBytes == null)
                {
                    qouteDTO.QouteImg = qouteDTO.QouteImg;
                }
                else
                {
                    var outputhandler = await FileHandler.SaveFileFromByte(qouteDTO.ImgBytes, qouteDTO.FileName, FolderName);

                    if (outputhandler.IsErrorOccured)
                    {
                        if (outputhandler.IsErrorKnown)
                        {
                            return(new OutputHandler
                            {
                                IsErrorOccured = true,
                                Message = outputhandler.Message
                            });
                        }
                        return(new OutputHandler
                        {
                            IsErrorOccured = true,
                            Message = "Something went wrong while the system tried to upload the file"
                        });
                    }
                    qouteDTO.QouteImg = outputhandler.ImageUrl;
                }
                var mapped = new AutoMapper <QouteDTO, Qoute>().MapToObject(qouteDTO);
                await _qouteRepository.UpdateAsync(mapped);

                await _qouteRepository.SaveChangesAsync();

                if (qouteDTO.OldImageUrl == null)
                {
                }
                else
                {
                    if (qouteDTO.ImgBytes == null) //if Byte[] is null means image is not being updated
                    {
                    }
                    else // only delete if artwork is not null meaning image is being updated
                    //delete old file
                    {
                        var outputHandler = await FileHandler.DeleteFileFromFolder(qouteDTO.OldImageUrl, FolderName);

                        if (outputHandler.IsErrorOccured) //True means Delete was not successful for some reason
                        {
                            return(new OutputHandler
                            {
                                IsErrorKnown = true,
                                IsErrorOccured = true,
                                Message = "Qoute Details updated successfully, but deleting of old file failed, please alert Techarch Team"
                            });
                        }
                    }
                }

                return(new OutputHandler
                {
                    IsErrorOccured = false,
                    Message = "Qoute Updated Successfully"
                });
            }
            catch (Exception ex)
            {
                return(StandardMessages.getExceptionMessage(ex));
            }
        }
예제 #28
0
 public IEnumerable <UserModel> Get()
 {
     return(AutoMapper <IEnumerable <BUsers>, List <UserModel> > .Map(userService.GetUsers));
 }
 public AuthorBook Get(int id)
 {
     return(AutoMapper <BUsersBook, AuthorBook> .Map(userBookService.GetUserBook, id));
 }
 public IEnumerable <TDestination> MapDynamicToEnumerable <TDestination>(List <object> source, bool keepCache = true) where TDestination : class
 {
     return((source != null) ? AutoMapper.MapDynamic <TDestination>(source, keepCache && !RemoveCacheAfterExecuteQuery) : null);
 }
        public static MaterialRegisterSubSeriesVM MapMaterialRegisterSubSeries(MaterialRegisterSubSeries materialRegisterSubSeries)
        {
            var materialRegisterSubSeriesVM = AutoMapper.Map <MaterialRegisterSubSeries, MaterialRegisterSubSeriesVM>(materialRegisterSubSeries);

            return(materialRegisterSubSeriesVM);
        }
예제 #32
0
        public ActionResult CreateOrEdit(int?id = 0)
        {
            UserModel user = AutoMapper <BUsers, UserModel> .Map(userService.GetUser, (int)id);

            return(View(user));
        }
예제 #33
0
 public static MyClass FromMyClassDto(MyClassDto myClassDto)
 {
     return(AutoMapper.LoadEntityFromDto <MyProject.DTO.MyClassDto, MyClass>(myClassDto));
 }
예제 #34
0
 public void Put(int id, UserModel value)
 {
     userService.CreateOrUpdate(AutoMapper <UserModel, BUsers> .Map(value));
 }
예제 #35
0
 public UserModel Get(int id)
 {
     return(AutoMapper <BUsers, UserModel> .Map(userService.GetUser, id));;
 }
예제 #36
0
 public ActionResult Delete(int id)
 {
     bookService.DeleteBook(id);
     return(PartialView("ViewBooks", AutoMapper <IEnumerable <BBook>, List <BookModel> > .Map(bookService.GetBooks)));
 }
 public ActionResult Index()
 {
     return(View(AutoMapper <IEnumerable <BUsersBook>, List <AuthorBook> > .Map(userBookService.GetUsersBooks)));
 }
예제 #38
0
        // GET: History
        public async Task <ActionResult> Index()
        {
            IEnumerable <History> historyList        = null;
            List <GetHistoryForm> getHistoryformList = new List <GetHistoryForm>();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(Baseurl);
                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                HttpResponseMessage Res = await client.GetAsync("History/Get");

                if (Res.IsSuccessStatusCode)
                {
                    var EmpResponse = Res.Content.ReadAsStringAsync().Result;
                    historyList = JsonConvert.DeserializeObject <List <History> >(EmpResponse);
                }
                foreach (History History in historyList)
                {
                    getHistoryformList.Add(AutoMapper <History, GetHistoryForm> .AutoMap(History));
                }
            }

            List <GetCarForm> getcarformList = await CarController.GetCarList();

            List <GetSellerForm> getsellerformList = await SellerController.GetSellerList();

            List <GetBuyerForm> getbuyerformList = await BuyerController.GetBuyerList();


            foreach (var item in getHistoryformList)
            {
                var data = (from b in getcarformList
                            where b.IdCar == item.IdCar
                            select b.ModelName).FirstOrDefault();

                var data2 = (from b in getcarformList
                             where b.IdCar == item.IdCar
                             select b.ChassisNumber).FirstOrDefault();

                item.CarName = data + " - " + data2;
            }

            foreach (var item in getHistoryformList)
            {
                var data = (from b in getsellerformList
                            where b.IdSeller == item.IdSeller
                            select b.Name).FirstOrDefault();

                item.SellerName = data;
            }

            foreach (var item in getHistoryformList)
            {
                var data1 = (from b in getbuyerformList
                             where b.IdBuyer == item.IdBuyer
                             select b.FirstName).FirstOrDefault();
                var data2 = (from b in getbuyerformList
                             where b.IdBuyer == item.IdBuyer
                             select b.LastName).FirstOrDefault();

                item.BuyerName = data1 + ' ' + data2;
            }



            return(View(getHistoryformList));
        }
예제 #39
0
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap<Edit, BaseProject.Model.Code>();
     configuration.CreateMap<BaseProject.Model.Code, Edit>();
 }
예제 #40
0
        public static string GetReactionSchemeFromReactionTable(DataTable rxnData, bool atomAutoMap)
        {
            string strMolFile = "";

            try
            {
                if (rxnData != null)
                {
                    RxnMolecule rxnMol = new RxnMolecule();
                    MolHandler  mHandler1;

                    //Add Reactants to RxnMol
                    for (int i = 0; i < rxnData.Rows.Count; i++)
                    {
                        if (rxnData.Rows[i]["PRPNT_TYPE"].ToString().ToUpper() == "REACTANT")
                        {
                            mHandler1 = new MolHandler(rxnData.Rows[i]["PRPNT_STRUCTURE"].ToString());
                            rxnMol.addComponent(mHandler1.getMolecule(), 0, true);
                        }
                    }

                    //Add Products to RxnMol
                    for (int i = 0; i < rxnData.Rows.Count; i++)
                    {
                        if (rxnData.Rows[i]["PRPNT_TYPE"].ToString().ToUpper() == "PRODUCT")
                        {
                            mHandler1 = new MolHandler(rxnData.Rows[i]["PRPNT_STRUCTURE"].ToString());
                            rxnMol.addComponent(mHandler1.getMolecule(), 1, true);
                        }
                    }

                    //string strSmiles = rxnMol.exportToFormat("smiles");
                    RxnMolecule rxnMolecule = RxnMolecule.getReaction(MolImporter.importMol(rxnMol.toFormat("mol")));

                    //If Auto mapping is checked
                    if (atomAutoMap)
                    {
                        AutoMapper mapper = new AutoMapper();
                        mapper.setMappingStyle(AutoMapper.MATCHING);
                        try
                        {
                            mapper.map(rxnMolecule);
                        }
                        catch
                        {
                        }
                    }

                    //MolHandler mh = new MolHandler(rxnMolecule.toFormat("mol"));
                    //mh.clean(true, "2D");
                    //strMolFile = mh.toFormat("mol");// reaction.toFormat("mol");

                    strMolFile = rxnMolecule.toFormat("mol");

                    #region Code commented
                    //AutoMapper mapper = new AutoMapper();
                    ////Molecule mol = MolImporter.importMol(rxnMol.exportToFormat("smiles"));
                    //// RxnMolecule rm = RxnMolecule.getReaction(mol);
                    //mapper.setReaction(rxnMol);
                    //mapper.setMappingStyle(AutoMapper.CHANGING);
                    //mapper.map(rxnMol, true);

                    //AutoMapper.mapReaction(rxnMol);

                    //MolImporter importer = new MolImporter("unmapped.smiles");
                    //MolExporter exporter = new MolExporter("mapped.mol", "sdf");
                    //AutoMapper.mapReaction(importer, exporter);
                    //importer.close();
                    //exporter.close();

                    //MDL.Draw.Modules.Editor.Actions.Calcs.
                    //GenericEditorModule mod = RenditorRxnScheme;
                    //MDL.Draw.Modules.Editor.Actions.Calcs.AutoMapAction mp = new MDL.Draw.Modules.Editor.Actions.Calcs.AutoMapAction();
                    //mp.Editor.AppendStructureToEditor(rxnMol.toFormat("mol"));

                    //RenditorRxnScheme.Preferences.AtomAtomDisplayMode = MDL.Draw.Renderer.Preferences.AtomAtomMappingDisplayMode.On;
                    //RenditorRxnScheme.Preferences.AtomChargeDisplay = true;
                    //RenditorRxnScheme.Preferences.StereoChemistryMode = MDL.Draw.Renderer.Preferences.StereoChemistryModeEnum.Absolute;

                    //RenditorRxnScheme.Preferences.ReactionCenterSize = 5.5;

                    //RenditorRxnScheme.Preferences.
                    //RenditorRxnScheme.MolfileString = rxnMol.toFormat("mol");
                    #endregion
                }
            }
            catch (Exception ex)
            {
                ErrorHandling.WriteErrorLog(ex.ToString());
            }
            return(strMolFile);
        }
 public void Put(int id, AuthorBook value)
 {
     userBookService.CreateOrUpdate(AutoMapper <AuthorBook, BUsersBook> .Map(value));
 }
예제 #42
0
        public ActionResult GetWorks(string filter = null)
        {
            var workList = workServ.GetWorks().Join(userServ.GetUsers(),
                                                    w => w.UserId,
                                                    u => u.Id, (w, u) => new { Id = w.Id, Name = w.Name, DateOfPublication = w.DateOfPublication, Content = w.Content, IsDelete = u.IsDelete, Username = u.Login, GenreId = w.GenreId }).Join(genreServ.GetGenres(),
                                                                                                                                                                                                                                              w => w.GenreId,
                                                                                                                                                                                                                                              g => g.Id, (w, g) => new InfoModel {
                Id = w.Id, Name = w.Name, DateOfPublication = w.DateOfPublication.Date, Content = w.Content, UserName = w.Username, GenreName = g.Name, IsDelete = w.IsDelete
            }).ToList();

            foreach (var item in workList)
            {
                if (item.IsDelete == true)
                {
                    item.UserName = "******";
                }
            }


            ViewBag.WorksList = filter == null ? workList : workList.Where(x => x.Name.Contains(filter) || x.GenreName.Contains(filter) || x.UserName.Contains(filter));

            return(View("_WorksTable", filter == null ? AutoMapper <IEnumerable <WorksBO>, List <WorksViewModel> > .Map(workServ.GetWorks())  : AutoMapper <IEnumerable <WorksBO>, List <WorksViewModel> > .Map(workServ.GetWorks().Where(x => x.Name.Contains(filter)).ToList())));
        }
예제 #43
0
 public IEnumerable <BBoard> GetList()
 {
     return(AutoMapper <IEnumerable <Board>, List <BBoard> > .Map(Database.Board.GetAll));
 }
 public TDestination MapDynamicToFirstOrDefault <TDestination>(IList <object> source, bool keepCache = true) where TDestination : class
 {
     return(source == null ? null : AutoMapper.MapDynamic <TDestination>(source, keepCache && !RemoveCacheAfterExecuteQuery).FirstOrDefault());
 }
예제 #45
0
 public IEnumerable <BUsers> GetList()
 {
     return(AutoMapper <IEnumerable <Users>, List <BUsers> > .Map(Database.Users.GetAll));
 }
예제 #46
0
 public async Task<ActionResult> GetGold()
 {
     Core.Models.TradeGoldModel model = await _mt4Service.GetAllGold(LoginAccount.MT4Account);
     var result = new { Profit = model.SumProfit.ToString("F2"), Gold = model.SumGold.ToString("f2") };
     return Json(result, JsonRequestBehavior.AllowGet);
 }
예제 #47
0
        private void deleteAutoButton_Click(object sender, EventArgs e)
        {
            var autoToDelete = AutoMapper.FromModelToEntity((AutoModel)clientAutosListBox.SelectedItem);

            sessionData.autoRepository.DeleteAuto(autoToDelete.AutoId);
        }
예제 #48
0
 public ActionResult Index()
 {
     return(View(AutoMapper <IEnumerable <BAuthor>, List <AuthorModel> > .Map(authorService.GetAuthors)));
 }
예제 #49
0
 private void ordersListBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     sessionData.selectedAuto  = AutoMapper.FromModelToEntity((AutoModel)clientAutosListBox.SelectedItem);
     modifyOrderButton.Visible = true;
     deleteOrderButton.Visible = true;
 }
예제 #50
0
 public ActionResult Delete(int id)
 {
     authorService.DeleteAuthor(id);
     return(PartialView("ViewAuthors", AutoMapper <IEnumerable <BAuthor>, List <AuthorModel> > .Map(authorService.GetAuthors)));
 }
예제 #51
0
 public ComponentStep(IAutomappingConfiguration cfg, AutoMapper mapper)
 {
     this.cfg = cfg;
     this.mapper = mapper;
 }
예제 #52
0
        public override void ConfigureMappings(AutoMapper.IConfiguration config, Umbraco.Core.ApplicationContext applicationContext)
        {
            //FROM SearchResult TO MemberListItem - used when searching for members.
            config.CreateMap<SearchResult, MemberListItem>()
                //.ForMember(member => member.Id, expression => expression.MapFrom(result => result.Id))
                .ForMember(member => member.Key, expression => expression.Ignore())

                .ForMember(member => member.LoginName,
                    expression => expression.MapFrom(result => result.Fields["loginName"]))

                .ForMember(member => member.Name,
                    expression => expression.MapFrom(result => result.Fields["nodeName"]))

                .ForMember(member => member.ContentType,
                    expression => expression.MapFrom(result => ApplicationContext.Current.Services.MemberTypeService.Get(result.Fields["nodeTypeAlias"])))

                .ForMember(member => member.Email,
                    expression => expression.MapFrom(result =>
                        result.Fields.ContainsKey("email") ? result.Fields["email"] : string.Empty))

                .ForMember(member => member.IsApproved, expression => expression.Ignore())

                .ForMember(member => member.IsLockedOut, expression => expression.Ignore())

                .ForMember(member => member.Icon, expression => expression.Ignore())
                .ForMember(member => member.Properties, expression => expression.Ignore())

                .AfterMap((searchResult, member) =>
                {
                    if (searchResult.Fields.ContainsKey("__key") && searchResult.Fields["__key"] != null)
                    {
                        Guid key;
                        if (Guid.TryParse(searchResult.Fields["__key"], out key))
                        {
                            member.Key = key;
                        }
                    }

                    bool val = true;
                    // We assume not approved for this property.
                    member.IsApproved = false;
                    // We assume not locked out for this property.
                    member.IsLockedOut = false;

                    if (!searchResult.Fields.ContainsKey(Constants.Conventions.Member.IsApproved) ||
                        !searchResult.Fields.ContainsKey(Constants.Conventions.Member.IsLockedOut))
                    {
                        // We need to get a member back from the database as these values aren't indexed reliably for some reason.
                        var m = ApplicationContext.Current.Services.MemberService.GetByKey((Guid)member.Key);
                        if (m != null)
                        {
                            member.IsApproved = m.IsApproved;
                            member.IsLockedOut = m.IsLockedOut;
                        }
                    }
                    else
                    {
                        if (searchResult.Fields[Constants.Conventions.Member.IsApproved] == "1")
                            member.IsApproved = true;
                        else if (bool.TryParse(searchResult.Fields[Constants.Conventions.Member.IsApproved], out val))
                            member.IsApproved = val;

                        if (searchResult.Fields[Constants.Conventions.Member.IsLockedOut] == "1")
                            member.IsLockedOut = true;
                        else if (bool.TryParse(searchResult.Fields[Constants.Conventions.Member.IsLockedOut], out val))
                            member.IsLockedOut = val;
                    }

                    // Get any other properties available from the fields.
                    foreach (var field in searchResult.Fields)
                    {
                        if (!field.Key.StartsWith("_") && !field.Key.StartsWith("umbraco") && !field.Key.EndsWith("_searchable") &&
                            field.Key != "id" && field.Key != "key" && 
                            field.Key != "updateDate" && field.Key != "writerName" &&
                            field.Key != "loginName" && field.Key != "email" &&
                            field.Key != Constants.Conventions.Member.IsApproved && 
                            field.Key != Constants.Conventions.Member.IsLockedOut &&
                            field.Key != "nodeName" && field.Key != "nodeTypeAlias")
                        {
                            member.Properties.Add(field.Key, field.Value);
                        }

                    }
                });

            config.CreateMap<ISearchResults, IEnumerable<MemberListItem>>()
                  .ConvertUsing(results => results.Select(Mapper.Map<MemberListItem>));

            //FROM MemberListItem to MemberExportModel.
            config.CreateMap<MemberListItem, MemberExportModel>()
                .ForMember(member => member.MemberType,
                    expression => expression.MapFrom(item => item.ContentType.Name))
                .ForMember(member => member.Properties, expression => expression.Ignore())
                .AfterMap((listItem, member) =>
                    {
                        // Get any other properties available from the fields.
                        foreach (var p in listItem.Properties)
                        {
                            member.Properties.Add(p.Key, p.Value);
                        }
                    });

            config.CreateMap<IEnumerable<MemberListItem>, IEnumerable<MemberExportModel>>()
                  .ConvertUsing(results => results.Select(Mapper.Map<MemberExportModel>));

            //FROM SearchResult to MemberExportModel.
            config.CreateMap<SearchResult, MemberExportModel>()
                .ConvertUsing(result => Mapper.Map<MemberExportModel>(Mapper.Map<MemberListItem>(result)));

            config.CreateMap<IEnumerable<MemberListItem>, IEnumerable<MemberExportModel>>()
                  .ConvertUsing(items => items.Select(Mapper.Map<MemberExportModel>));
        }
예제 #53
0
        public void InsertRange_AddsModelsToDbSet()
        {
            IEnumerable<TestModel> models = new[] { ObjectFactory.CreateTestModel(1), ObjectFactory.CreateTestModel(2) };
            unitOfWork.InsertRange(models);

            IEnumerator<TestModel> actual = context.ChangeTracker.Entries<TestModel>().Select(entry => entry.Entity).GetEnumerator();
            IEnumerator<TestModel> expected = models.GetEnumerator();

            while (expected.MoveNext() | actual.MoveNext())
            {
                Assert.Equal(EntityState.Added, context.Entry(actual.Current).State);
                Assert.Same(expected.Current, actual.Current);
            }
        }
        public async Task <GridModel <Product> > Shop_GetListProductPG(RequestParams pr)
        {
            SQLParameters sqlParams = new SQLParameters();

            sqlParams.Add_Parameter("@_ProductCategoryId", pr.ProductCategoryId);
            sqlParams.Add_Parameter("@_Conditional", pr.Conditional);
            sqlParams.Add_Parameter("@_PageIndex", pr.PageIndex);
            sqlParams.Add_Parameter("@_PageSize", pr.PageSize);
            var tbl = _db.ExecuteToDataset("usp_Product_GetListByConditional", sqlParams, ExecuteType.StoredProcedure);
            await Task.FromResult(tbl);

            GridModel <Product> listProduct = new GridModel <Product>();

            listProduct.Data = (tbl.Tables[0] != null && tbl.Tables[0].Rows.Count > 0) ? AutoMapper <Product> .Map(tbl.Tables[0]) : new List <Product>();

            listProduct.TotalPage   = (tbl.Tables[1] != null && tbl.Tables[1].Rows.Count > 0) ? (int)tbl.Tables[1].Rows[0][0] : 0;
            listProduct.CurrentPage = pr.PageIndex;
            listProduct.SizePage    = pr.PageSize;

            return(listProduct);
        }
예제 #55
0
 public IEnumerable <BGenre> GetGenres()
 {
     return(AutoMapper <IEnumerable <Genre>, List <BGenre> > .Map(Database.Genre.GetAll));
 }
예제 #56
0
        public BBoard Get(int id)
        {
            if (id > 0)
            {
                BBoard board = AutoMapper <Board, BBoard> .Map(Database.Board.Get(id));

                board.Fields = AutoMapper <IEnumerable <Field>, List <BField> > .Map(Database.Field.Find(i => i.BoardId == id));

                board.Fields.Where(z => z.CheckId != null).ToList().ForEach(i => i.Check = AutoMapper <Check, BCheck> .Map(Database.Check.Get((int)i.CheckId)));
                return(board);
            }
            else
            {
                return(new BBoard());
            }
        }
예제 #57
0
        public async Task <GridModel <Framework.Entities.Payments.Payment> > ViewHistory(RequestParams pr)
        {
            SQLParameters sqlParams = new SQLParameters();

            sqlParams.Add_Parameter("@_AccountId", pr.AccountId);
            sqlParams.Add_Parameter("@_PageSize", pr.PageSize);
            sqlParams.Add_Parameter("@_PageIndex", pr.PageIndex);

            var tbl = _db.ExecuteToDataset("usp_Payment_ViewHistory", sqlParams, ExecuteType.StoredProcedure);
            await Task.FromResult(tbl);

            GridModel <Framework.Entities.Payments.Payment> listHistory = new GridModel <Framework.Entities.Payments.Payment>();

            listHistory.Data = (tbl.Tables[0] != null && tbl.Tables[0].Rows.Count > 0) ? AutoMapper <Framework.Entities.Payments.Payment> .Map(tbl.Tables[0]) : new List <Framework.Entities.Payments.Payment>();

            listHistory.TotalPage   = (tbl.Tables[1] != null && tbl.Tables[1].Rows.Count > 0) ? (int)tbl.Tables[1].Rows[0][0] : 0;
            listHistory.CurrentPage = pr.PageIndex;
            listHistory.SizePage    = pr.PageSize;

            return(listHistory);
        }
예제 #58
0
        public async Task<bool> SendConfirmEmail(Guid userId)
        {
            try
            {
                var user = Services.Users.GetUserById(userId);
                var code = await _userManager.GenerateEmailConfirmationTokenAsync(user.Id);

                var callbackUrl = Url.Action("ConfirmEmail", "Account", new { id = user.Id, code = code }, protocol: Request.Url.Scheme);

                string content = null;

                content = string.Format(Web.Code.Constants.ActivationCodeNotification, code);

                var transfromWith = new
                {
                    BaseUrl = AppSettings.BaseUrl,
                    SentDate = DateTime.Now.ToString(Web.Code.Constants.GlobalDateTimeFormat),
                    //If name is empty, use provided userName.
                    Name = (string.IsNullOrWhiteSpace(user.FirstName) && string.IsNullOrWhiteSpace(user.LastName)) 
                        ? user.UserName : user.Name,
                    ActivationLink = callbackUrl,
                    MobileCodeNotification = content
                };

                List<string> toAddresses = new List<string> { user.Email };
                await Services.Mail.SendMail(ConstEmailTemplateKey.ActivationEmailTemplate, toAddresses,
                    ConstEmailSubject.ActivationEmail, transfromWith, null);

                user.EmailConfirmationCode = code;
                user.ModifiedDate = DateTime.UtcNow;
                Services.Users.UpdateUserInfo(user);

                return true;
            }
            catch (Exception ex)
            {
                Log.Error("Send confirm email", ex);
                return false;
            }
        }
예제 #59
0
        public async Task<ActionResult> ForgotPassword(ForgotPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await _userManager.FindByNameAsync(model.EmailForgot);

                if (user == null)
                {
                    return Json(new { Status = false, Error = NotificationMessage.ErrorWhenConfirmEmailForForgotPassword });
                }

                // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                // Send an email with this link
                string code = await _userManager.GeneratePasswordResetTokenAsync(user.Id);
                var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);

                var transfromWith = new
                {
                    BaseUrl = AppSettings.BaseUrl,
                    SentDate = DateTime.Now.ToString(Web.Code.Constants.GlobalDateTimeFormat),
                    Name = user.FirstName + " " + user.LastName,
                    ResetLink = callbackUrl,
                };

                List<string> toAddresses = new List<string> { user.Email };
                await Services.Mail.SendMail(TeleConsult.Infrastructure.Core.Const.ConstEmailTemplateKey.ResetPasswordTemplate, toAddresses,
                    "TeleConsult - Reset your password", transfromWith, null);

                return Json(new { Status = true });
            }
            return Json(new { Status = false, Error = "Invalid email" });
        }
예제 #60
-1
 public void CreateMappings(AutoMapper.IConfiguration configuration)
 {
     configuration.CreateMap<Operador, UsuarioDto>()
         .ForMember(m => m.Denominacion, opt =>
                                 opt.MapFrom(u => u.Personal.Nombre))
         .ForMember(m => m.Cuit, opt =>
                                 opt.MapFrom(u => u.Personal.Cuit))
         .ForMember(m => m.Domicilio, opt =>
                                      opt.MapFrom(u => u.Personal.Domicilio))
         .ForMember(m => m.Telefono, opt =>
                                     opt.MapFrom(u => u.Personal.Telefono))
         .ForMember(m => m.Celular, opt =>
                                    opt.MapFrom(u => u.Personal.Celular))
         .ForMember(m => m.HoraDesdeT, opt =>
                                       opt.MapFrom(u => u.Personal.HoraDesdeT))
         .ForMember(m => m.HoraHastaT, opt =>
                                       opt.MapFrom(u => u.Personal.HoraHastaT))
         .ForMember(m => m.Localidad, opt =>
                                       opt.MapFrom(u => u.Personal.Localidad.Nombre))
         .ForMember(m => m.Provincia, opt =>
                                       opt.MapFrom(u => u.Personal.Provincia.Nombre));
 }