public void Test1() { ViewModelMapper mapper = new ViewModelMapper(); Person p1 = new Person(); p1.FirstName = "Fred"; p1.LastName = "Flintstone"; p1.UserName = "******"; p1.EmailAddress = "*****@*****.**"; PersonViewModel p2 = new PersonViewModel(); mapper.Map<Person, PersonViewModel>(p1, p2); }
public IActionResult TakeRepayLoan(LoanTransactionViewModel transactionVM) { dynamic transaction = null; if (transactionVM.NomorAnggota <= 0) { return(View(transactionVM)); } if (transactionVM.JenisTransaksi == LoanTransactionType.PinjamanUang) { if (transactionVM.PersentaseBunga < 0 || transactionVM.JumlahPinjaman <= 0) { return(View(transactionVM)); } transaction = ViewModelMapper.MapViewModelToModel(transactionVM, new LoanTransactionModel()); } else { if (transactionVM.JumlahPinjamanPokok <= 0 || transactionVM.JumlahBungaPinjaman <= 0 || transactionVM.NomorPinjaman <= 0) { return(View(transactionVM)); } // Validate the loan belongs to the member var loanExists = _loanService.GetById(transactionVM.NomorPinjaman); if (loanExists == null) { ModelState.AddModelError("", "Nomor pinjaman tidak ada untuk nomor anggota ini."); // Member list transactionVM.DaftarAnggota = _memberService.GetMembers(); return(View(transactionVM)); //return RedirectToAction("TakeRepayLoan", transactionVM); } transaction = ViewModelMapper.MapViewModelToModel(transactionVM, new LoanRepaymentTransactionModel()); } if (transactionVM.JenisTransaksi == LoanTransactionType.PinjamanUang) { _loanService.Save(transaction); } else { _loanRepaymentService.Save(transaction); } return(RedirectToAction(nameof(ClearForm), new { ActionName = "TakeRepayLoan" })); }
public ActionResult Index(string firstName, string lastName) { string storeLoc = TempData.Peek("adminLoc").ToString(); Dictionary <string, CCustomer> customers = _storeRepo.GetAllCustomersAtOneStore(storeLoc); var viewCustomer = ViewModelMapper.MapCustomers(customers); if (!String.IsNullOrEmpty(firstName) && !String.IsNullOrEmpty(lastName)) { // get var searchedCustomers = _storeRepo.GetAllCustomersAtOneStoreByName(storeLoc, firstName, lastName); viewCustomer = ViewModelMapper.MapCustomers(searchedCustomers); } return(View(viewCustomer)); }
public IHttpActionResult DeleteJobType(int id) { JobType jobType = db.JobTypes.Find(id); if (jobType == null) { return(NotFound()); } db.JobTypes.Remove(jobType); db.SaveChanges(); return(Ok(ViewModelMapper.ToViewModelJobTypes(jobType))); }
protected virtual List <DailyScheduleExceptionViewModel> GetOpeningHourExceptions(CreateStoreViewModelParam param, DateTime today) { var exceptions = StoreScheduleProvider.GetOpeningHourExceptions(param.Store.StoreSchedule, today, 1); return(exceptions.Select( ex => ViewModelMapper.MapTo <DailyScheduleExceptionViewModel>(new { ex.StartDate, ex.EndDate, ex.IsClosed, OpeningTime = GetScheduleIntervalViewModel(ex.OpeningTime, param.CultureInfo) }, param.CultureInfo)) .ToList()); }
protected virtual List <DailyScheduleExceptionViewModel> GetOpeningHourExceptions(FulfillmentSchedule schedule, CultureInfo cultureInfo, DateTime today) { var exceptions = StoreScheduleProvider.GetOpeningHourExceptions(schedule, today, 1); return(exceptions.Select( ex => ViewModelMapper.MapTo <DailyScheduleExceptionViewModel>(new { ex.StartDate, ex.EndDate, ex.IsClosed, OpeningTime = GetScheduleIntervalViewModel(ex.OpeningTime, cultureInfo) }, cultureInfo)) .ToList()); }
public IHttpActionResult DeleteAccomodation(int id) { Accomodation accomodation = db.Accomodations.Find(id); if (accomodation == null) { return(NotFound()); } db.Accomodations.Remove(accomodation); db.SaveChanges(); return(Ok(ViewModelMapper.ToViewModelAccomodations(accomodation))); }
public virtual CartViewModel CreateCartViewModel(CreateCartViewModelParam param) { if (param == null) { throw new ArgumentNullException("param"); } if (param.CultureInfo == null) { throw new ArgumentNullException("CultureInfo"); } if (param.ProductImageInfo == null) { throw new ArgumentNullException("ProductImageInfo"); } if (param.ProductImageInfo.ImageUrls == null) { throw new ArgumentNullException("ImageUrls"); } if (string.IsNullOrWhiteSpace(param.BaseUrl)) { throw new ArgumentException("BaseUrl"); } var vm = ViewModelMapper.MapTo <CartViewModel>(param.Cart, param.CultureInfo); if (vm == null) { return(null); } vm.OrderSummary = GetOrderSummaryViewModel(param.Cart, param.CultureInfo); MapShipmentsAndPayments(param.Cart, param.CultureInfo, param.ProductImageInfo, param.BaseUrl, param.PaymentMethodDisplayNames, vm, param.Cart.Payments); MapCustomer(param.Cart.Customer, param.CultureInfo, vm); vm.Coupons = GetCouponsViewModel(param.Cart, param.CultureInfo, param.IncludeInvalidCouponsMessages); vm.OrderSummary.AdditionalFeeSummaryList = GetAdditionalFeesSummary(vm.LineItemDetailViewModels, param.CultureInfo); SetDefaultCountryCode(vm); SetPostalCodeRegexPattern(vm); SetPhoneNumberRegexPattern(vm); // Reverse the items order in the Cart so the last added item will be the first in the list if (vm.LineItemDetailViewModels != null) { vm.LineItemDetailViewModels.Reverse(); } vm.IsAuthenticated = ComposerContext.IsAuthenticated; return(vm); }
// placeholder for more information in the future public ActionResult Details(string id) { string storeLoc = TempData.Peek("adminLoc").ToString(); CProduct foundProduct = _storeRepo.GetOneProductWithQuantity(storeLoc, id); // concurrent if (foundProduct == null) { ModelState.AddModelError("", "Another admin has just deleted this product"); return(View()); } var viewProduct = ViewModelMapper.MapSingleDetailedProduct(foundProduct); return(View(viewProduct)); }
public IHttpActionResult PostUser(UserViewModel userViewModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } User user = new User { UserName = userViewModel.UserName, Email = userViewModel.Email, FirstName = userViewModel.FirstName, LastName = userViewModel.LastName, JobTypeId = userViewModel.JobTypeId }; var result = UserManager.CreateAsync(user).Result; return(CreatedAtRoute("DefaultApi", new { id = user.Id }, ViewModelMapper.ToViewModelUsers(user))); }
public IEnumerable <ApplicationUserViewModel> Get(string searchstring = null) { var result = _userManager.Users; if (!String.IsNullOrEmpty(searchstring)) { result = result.Where(user => user.FULLNAME.ToLower().Contains(searchstring.ToLower()) || user.Email.ToLower().Contains(searchstring.ToLower()) || user.UserName.ToLower().Contains(searchstring.ToLower()) || user.PHONE.ToString().Contains(searchstring.ToLower())); } var model = ViewModelMapper <ApplicationUserViewModel, ApplicationUser> .MapObjects(result.ToList(), null); return(model.ToList()); }
public MenuItemController( IMenuItemManager menuItemManager, ICategoryManager categoryManager, ISubCategoryManager subCategoryManager, ViewModelMapper viewModelMapper, IWebHostEnvironment webHostEnvironment ) { _webHostEnvironment = webHostEnvironment; _viewModelMapper = viewModelMapper; _menuItemManager = menuItemManager; _categoryManager = categoryManager; _subCategoryManager = subCategoryManager; menuItemAndSubCListAndCListVm = new MenuItemAndSubCListAndCListViewModel(); }
public HostedLayoutPageViewModel(HostedLayoutPage model) : base(model) { RemoveItem = new RelayCommand(OnRemoveItem, CanExecuteRemoveItem); var lst = new List <HostedLayoutItemViewModel>(); foreach (var x in model.Items) { HostedLayoutItemViewModel vm = null; vm = (ContentAreaViewModel)ViewModelMapper.GetViewModel(x); if (vm == null) { if (x is ContentArea) { vm = new ContentAreaViewModel(x); } else if (x is ToggleItem) { vm = new ToggleItemViewModel(x); } else if (x is ButtonItem) { vm = new ButtonItemViewModel(x); } else if (x is InteractableItem) { vm = new InteractableItemViewModel(x); } } if (vm == null) { continue; } vm.Parent = this; lst.Add(vm); } _items = new ViewModelCollection <HostedLayoutItemViewModel, HostedLayoutItem>(model.Items, lst); _items.CollectionChanged += items_CollectionChanged; ContentAreas = new ObservableCollection <ContentAreaViewModel>(_items.Where(x => x is ContentAreaViewModel).Cast <ContentAreaViewModel>().ToList()); }
/// <summary> /// Get the view Model to display a Create Account Form and Form result /// </summary> /// <param name="param">Builder params <see cref="GetCreateAccountViewModelParam"/></param> /// <returns> /// The view model to display the Create Account Form /// </returns> public virtual CreateAccountViewModel GetCreateAccountViewModel(GetCreateAccountViewModelParam param) { var viewModel = ViewModelMapper.MapTo <CreateAccountViewModel>(param.Customer, param.CultureInfo) ?? new CreateAccountViewModel(); viewModel.TermsAndConditionsUrl = param.TermsAndConditionsUrl; viewModel.Status = param.Status?.ToString("G") ?? string.Empty; viewModel.ReturnUrl = param.ReturnUrl; viewModel.IsSuccess = param.Status == MyAccountStatus.Success; viewModel.Username = param.Customer != null ? param.Customer.Username : string.Empty; viewModel.CustomerId = param.Customer?.Id ?? Guid.Empty; viewModel.Created = param.Customer?.Created ?? DateTime.MinValue; SetPasswordValidationRules(viewModel); return(viewModel); }
protected virtual OrderDetailInfoViewModel GetOrderInfosViewModel(CreateOrderDetailViewModelParam param) { if (param.Order.Cart.Total == null) { throw new ArgumentNullException("param.Order.Cart.Total"); } var orderInfos = ViewModelMapper.MapTo <OrderDetailInfoViewModel>(param.Order, param.CultureInfo); orderInfos.OrderStatus = param.OrderStatuses[param.Order.OrderStatus]; orderInfos.OrderStatusRaw = param.Order.OrderStatus; orderInfos.BillingCurrency = param.Order.Cart.BillingCurrency; orderInfos.PricePaid = LocalizationProvider.FormatPrice((decimal)param.Order.Cart.Total, param.CultureInfo); return(orderInfos); }
public virtual RecurringOrderProgramViewModel CreateRecurringOrderProgramViewModel(RecurringOrderProgram program, CultureInfo culture) { if (program == null) { throw new ArgumentNullException(nameof(program)); } if (culture == null) { throw new ArgumentNullException(nameof(culture)); } var vm = ViewModelMapper.MapTo <RecurringOrderProgramViewModel>(program, culture); if (vm == null) { return(null); } var programLocalized = program.Localizations?.FirstOrDefault(l => string.Equals(l.CultureIso, culture.Name, StringComparison.OrdinalIgnoreCase)); if (programLocalized != null) { vm.DisplayName = programLocalized.DisplayName; foreach (var frequency in program.Frequencies ?? Enumerable.Empty <RecurringOrderFrequency>()) { var vmFrequency = vm.Frequencies.FirstOrDefault(f => string.Equals(f.RecurringOrderFrequencyName, frequency.RecurringOrderFrequencyName, StringComparison.OrdinalIgnoreCase)); if (vmFrequency != null) { var localizlocalizedFrequency = frequency.Localizations.FirstOrDefault(l => string.Equals(l.CultureIso, culture.Name, StringComparison.OrdinalIgnoreCase)); if (localizlocalizedFrequency != null) { vmFrequency.DisplayName = localizlocalizedFrequency.DisplayName; } else { vmFrequency.DisplayName = vmFrequency.RecurringOrderFrequencyName; } } } } vm.Frequencies = vm.Frequencies.OrderBy(f => f.SequenceNumber).ToList(); return(vm); }
public virtual LightRecurringOrderCartViewModel CreateLightRecurringOrderCartViewModel(CreateLightRecurringOrderCartViewModelParam param) { if (param == null) { throw new ArgumentNullException(nameof(param)); } if (param.CultureInfo == null) { throw new ArgumentNullException(nameof(param.CultureInfo)); } if (param.ProductImageInfo == null) { throw new ArgumentNullException(nameof(param.ProductImageInfo)); } if (param.ProductImageInfo.ImageUrls == null) { throw new ArgumentNullException(nameof(param.ProductImageInfo.ImageUrls)); } if (string.IsNullOrWhiteSpace(param.BaseUrl)) { throw new ArgumentException(nameof(param.BaseUrl)); } var vm = ViewModelMapper.MapTo <LightRecurringOrderCartViewModel>(param.Cart, param.CultureInfo); vm.LineItemDetailViewModels = LineItemViewModelFactory.CreateLightViewModel(new CreateLightListOfLineItemDetailViewModelParam { Cart = param.Cart, LineItems = param.Cart.GetLineItems(), CultureInfo = param.CultureInfo, ImageInfo = param.ProductImageInfo, BaseUrl = param.BaseUrl }).ToList(); FillNextOcurrence(vm, param.Cart, param.CultureInfo); vm.CartDetailUrl = GetRecurringCartDetailUrl(param.CultureInfo, param.Cart.Name); // Reverse the items order in the Cart so the last added item will be the first in the list if (vm.LineItemDetailViewModels != null) { vm.LineItemDetailViewModels.Reverse(); } vm.IsAuthenticated = ComposerContext.IsAuthenticated; return(vm); }
/// <summary> /// Get the view Model to display a Reset Password Form and Form result /// </summary> /// <param name="param">Builder params <see cref="GetResetPasswordViewModelParam"/></param> /// <returns> /// The view model to display the Reset Password Form /// </returns> protected virtual ResetPasswordViewModel GetResetPasswordViewModel(GetResetPasswordViewModelParam param) { var viewModel = ViewModelMapper.MapTo <ResetPasswordViewModel>(param.Customer, param.CultureInfo) ?? new ResetPasswordViewModel(); viewModel.Status = param.Status.HasValue ? param.Status.Value.ToString("G") : string.Empty; viewModel.ForgotPasswordUrl = param.ForgotPasswordUrl; viewModel.ReturnUrl = param.ReturnUrl; SetPasswordValidationRules(viewModel); if (param.Customer == null) { viewModel.Status = MyAccountStatus.InvalidTicket.ToString("G"); } return(viewModel); }
public SettingsWindow(AppSettings settings) { _settings = settings; InitializeComponent(); vm = new SettingsViewModel(); vm.PropertyChanged += Vm_PropertyChanged; ViewModelMapper.SettingsViewModel(_settings, vm); var appTheme = ThemeManager.Current.DetectTheme(Application.Current); vm.SelectedColor = appTheme.ColorScheme; vm.UseDarkMode = appTheme.BaseColorScheme == "Dark"; this.DataContext = vm; }
public IActionResult GetGame(int?id) { if (id == null) { return(BadRequest("No such game found")); } var game = gameDataAccess.GetGame((int)id); if (game == null) { return(BadRequest("No such game found")); } GamePresentationModel gameModel = ViewModelMapper.MapGameToPresentation(game); return(Ok(gameModel)); }
/// <summary> /// Retrieve the list of RegionViewModel for a specified Country /// </summary> /// <param name="param"></param> /// <returns></returns> public virtual async Task <IEnumerable <RegionViewModel> > RetrieveRegionsAsync(RetrieveCountryParam param) { if (string.IsNullOrWhiteSpace(param.IsoCode)) { throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.IsoCode)), nameof(param)); } if (param.CultureInfo == null) { throw new ArgumentException(GetMessageOfNull(nameof(param.CultureInfo)), nameof(param)); } var regions = await CountryRepository.RetrieveRegions(param).ConfigureAwait(false); var regionsCountryModel = regions.Select(region => ViewModelMapper.MapTo <RegionViewModel>(region, param.CultureInfo)); return(regionsCountryModel); }
protected virtual OrderDetailInfoViewModel GetOrderInfosViewModel(CreateOrderDetailViewModelParam param) { if (param.Order.Cart.Total == null) { throw new ArgumentException(GetMessageOfNull(nameof(param.Order.Cart.Total)), nameof(param)); } var orderInfos = ViewModelMapper.MapTo <OrderDetailInfoViewModel>(param.Order, param.CultureInfo); orderInfos.OrderStatus = GetOrderStatusDisplayName(param); orderInfos.OrderStatusRaw = param.Order.OrderStatus; orderInfos.BillingCurrency = param.Order.Cart.BillingCurrency; orderInfos.PricePaid = LocalizationProvider.FormatPrice((decimal)param.Order.Cart.Total, CurrencyProvider.GetCurrency()); orderInfos.HasOwnDraft = HasOwnDraft(param); return(orderInfos); }
private void ConfigureMetadataRegistryForSerialization() { MetadataRegistry = _container.GetMock <IViewModelMetadataRegistry>(); ConfigureViewModelMetadata(typeof(CustomerSummaryViewModel), typeof(ICustomCustomerViewModel)); ConfigureViewModelMetadata(typeof(AddressViewModel)); ConfigureViewModelMetadata(typeof(ShippingMethodViewModel)); ConfigureViewModelMetadata(typeof(CartViewModel)); ConfigureViewModelMetadata(typeof(PaymentMethodViewModel)); ConfigureViewModelMetadata(typeof(PaymentViewModel)); ConfigureViewModelMetadata(typeof(BillingAddressViewModel)); ConfigureViewModelMetadata(typeof(RegisteredShippingAddressViewModel)); ViewModelMetadataRegistry.Current = MetadataRegistry.Object; ViewModelMapper = new ViewModelMapper(MetadataRegistry.Object, _container.GetMock <IViewModelPropertyFormatter>().Object, _container.GetMock <ILookupService>().Object, _container.GetMock <ILocalizationProvider>().Object); }
/// <summary> /// Get the view Model to display a Create Account Form and Form result /// </summary> /// <param name="param">Builder params <see cref="GetCreateAccountViewModelParam"/></param> /// <returns> /// The view model to display the Create Account Form /// </returns> public virtual CreateAccountViewModel GetCreateAccountViewModel(GetCreateAccountViewModelParam param) { var viewModel = ViewModelMapper.MapTo <CreateAccountViewModel>(param.Customer, param.CultureInfo) ?? new CreateAccountViewModel(); viewModel.MinRequiredPasswordLength = MembershipProvider.MinRequiredPasswordLength; viewModel.MinRequiredNonAlphanumericCharacters = MembershipProvider.MinRequiredNonAlphanumericCharacters; viewModel.PasswordRegexPattern = CreatePasswordRegexPattern().ToString(); viewModel.TermsAndConditionsUrl = param.TermsAndConditionsUrl; viewModel.Status = param.Status?.ToString("G") ?? string.Empty; viewModel.ReturnUrl = param.ReturnUrl; viewModel.IsSuccess = param.Status == MyAccountStatus.Success; viewModel.Username = param.Customer != null ? param.Customer.Username : string.Empty; viewModel.CustomerId = param.Customer?.Id ?? Guid.Empty; viewModel.Created = param.Customer?.Created ?? DateTime.MinValue; return(viewModel); }
protected virtual ActivePaymentViewModel MapActivePayment(Payment activePayment, CultureInfo cultureInfo) { var paymentProvider = PaymentProviderFactory.ResolveProvider(activePayment.PaymentMethod.PaymentProviderName); var activePaymentVm = ViewModelMapper.MapTo <ActivePaymentViewModel>(activePayment, cultureInfo); activePaymentVm.ShouldCapturePayment = paymentProvider.ShouldCapturePayment(activePayment); if (activePaymentVm.ShouldCapturePayment) { activePaymentVm.CapturePaymentUrl = paymentProvider.GetCapturePaymentUrl(activePayment, cultureInfo); } activePaymentVm.ProviderName = paymentProvider.ProviderName; activePaymentVm.ProviderType = paymentProvider.ProviderType; paymentProvider.AugmentViewModel(activePaymentVm, activePayment); return(activePaymentVm); }
// [Authorize(Roles = "ViewRole")] public IEnumerable <ApplicationRoleViewModel> Get(string searchstring = null) { try { var result = _appRoleService.GetAll(); if (!String.IsNullOrEmpty(searchstring)) { result = result.Where(role => role.Name.ToLower().Contains(searchstring.ToLower())); } var model = ViewModelMapper <ApplicationRoleViewModel, IdentityRole> .MapObjects(result.ToList(), null); return(model.ToList()); } catch (Exception ex) { return(new List <ApplicationRoleViewModel>()); } }
public IActionResult GetMatchHistory() { var user = userGetter.GetUserFromClaims(HttpContext); if (user == null) { return(BadRequest("U are not logged in")); } List <Game> games = new List <Game>(); User gamePlayer = userDataAccess.GetUser(user.UserID); games = gameDataAccess.GetGames(g => (g.PlayerWhiteID == gamePlayer.ID || g.PlayerBlackID == gamePlayer.ID) && g.WinnerID != null) .OrderByDescending(g => g.FinishedDate).ToList(); var gamesModels = games.Select(g => ViewModelMapper.MapGameToPresentation(g)); return(Ok(gamesModels)); }
public ActionResult CheckOrder() { string email = TempData.Peek("User").ToString(); CCustomer customer = _storeRepo.GetOneCustomerByEmail(email); string storeLoc = TempData.Peek("storeLoc").ToString(); CStore store = _storeRepo.GetOneStore(storeLoc); // collection information about this customer var OrderHistory = _storeRepo.GetOneCustomerOrderHistory(customer, store); if (OrderHistory == null) { return(View(new List <OrderViewModel>())); } var viewOrder = ViewModelMapper.MapOrders(OrderHistory); return(View(viewOrder)); }
// a list of products sold at that location public ActionResult Select(string storeLoc, string category) { if (storeLoc == null) { storeLoc = TempData.Peek("storeLoc").ToString(); } var products = _storeRepo.GetInventoryOfOneStore(storeLoc); var viewProduct = ViewModelMapper.MapBindedProducts(products); if (!String.IsNullOrEmpty(category)) { var foundProducts = _storeRepo.GetInventoryOfOneStoreByCategory(storeLoc, category); viewProduct = ViewModelMapper.MapBindedProducts(foundProducts); } TempData["storeLoc"] = storeLoc; TempData.Keep("storeLoc"); return(View(viewProduct)); }
public ContentAreaViewModel(HostedLayoutItem model) : base(model) { _clearContentCommand = new RelayCommand(OnClearContent); var contentArea = ModelAs <ContentArea>(); if (contentArea.HasContent) { var contentVm = ViewModelMapper.GetViewModel(contentArea.Content); if (contentVm == null) { contentVm = ContentItemViewModel.CreateItem(contentArea.Content); } Content = (ContentItemViewModel)contentVm; } }
/// <summary> /// Get the view Model to display a Reset Password Form and Form result /// </summary> /// <param name="param">Builder params <see cref="GetResetPasswordViewModelParam"/></param> /// <returns> /// The view model to display the Reset Password Form /// </returns> protected virtual ResetPasswordViewModel GetResetPasswordViewModel(GetResetPasswordViewModelParam param) { var viewModel = ViewModelMapper.MapTo <ResetPasswordViewModel>(param.Customer, param.CultureInfo) ?? new ResetPasswordViewModel(); viewModel.Status = param.Status.HasValue ? param.Status.Value.ToString("G") : string.Empty; viewModel.MinRequiredPasswordLength = MembershipProvider.MinRequiredPasswordLength; viewModel.MinRequiredNonAlphanumericCharacters = MembershipProvider.MinRequiredNonAlphanumericCharacters; viewModel.PasswordRegexPattern = CreatePasswordRegexPattern().ToString(); viewModel.ForgotPasswordUrl = param.ForgotPasswordUrl; viewModel.ReturnUrl = param.ReturnUrl; if (param.Customer == null) { viewModel.Status = MyAccountStatus.InvalidTicket.ToString("G"); } return(viewModel); }