当前位置: 首页>>代码示例>>C#>>正文


C# ViewModels类代码示例

本文整理汇总了C#中ViewModels的典型用法代码示例。如果您正苦于以下问题:C# ViewModels类的具体用法?C# ViewModels怎么用?C# ViewModels使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ViewModels类属于命名空间,在下文中一共展示了ViewModels类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessPayment

        public PaymentResult ProcessPayment(ViewModels.CheckoutViewModel model)
        {
            var request = new TransactionRequest()
            {
                Amount = model.Total,
                CreditCard = new TransactionCreditCardRequest()
                {
                    Number = model.CardNumber,
                    CVV = model.Cvv,
                    ExpirationMonth = model.Month,
                    ExpirationYear = model.Year
                },
                Options = new TransactionOptionsRequest()
                {
                    SubmitForSettlement = true
                }
            };

            var result = _gateway.Transaction.Sale(request);

            if (result.IsSuccess())
            {
                return new PaymentResult(result.Target.Id, true, null);
            }

            return new PaymentResult(null, false, result.Message);
        }
开发者ID:marley-cs,项目名称:build-a-store-with-a-payment-gateway-in-aspnet,代码行数:27,代码来源:PaymentGateway.cs

示例2: RegisterCustomer

        public bool RegisterCustomer(ViewModels.CustomerRegisterModel model)
        {
            using (var dbContext = new PaymentGatewayDbContext())
            {
                var customer = new Person
                {
                    FullName = model.FullName,
                    DoB = model.DoB
                };
                customer.Accounts.Add(new Account { Balance = model.InitialDeposit });

                var credential = new Credentials
                {
                    UserName = model.UserName,
                    Person = customer,
                    CreatedDate = DateTimeOffset.Now,
                    SecretKey = criptoService.GenerateRandomByte(512)
                };

                using (SHA512 shasum = SHA512.Create())
                {
                    credential.HashedPassword = shasum.ComputeHash(Encoding.Default.GetBytes(model.Password));
                }
                dbContext.Credentials.Add(credential);
                dbContext.SaveChanges();
                return true;
            }
        }
开发者ID:pavanputhra,项目名称:MITCSIS,代码行数:28,代码来源:DefaultRegistrationService.cs

示例3: AssignContact

        public ActionResult AssignContact(ViewModels.Events.EventAssignedContactViewModel model)
        {
            Common.Models.Account.Users currentUser;
            Common.Models.Events.EventAssignedContact eventContact;

            // We need to reset the Id of the model as it is picking up the id from the route,
            // which is incorrect
            model.Id = null;

            currentUser = Data.Account.Users.Get(User.Identity.Name);

            eventContact = Data.Events.EventAssignedContact.Get(model.Event.Id.Value, model.Contact.Id.Value);

            if (eventContact == null)
            { // Create
                eventContact = Mapper.Map<Common.Models.Events.EventAssignedContact>(model);
                eventContact = Data.Events.EventAssignedContact.Create(eventContact, currentUser);
            }
            else
            { // Enable
                eventContact = Mapper.Map<Common.Models.Events.EventAssignedContact>(model);
                eventContact = Data.Events.EventAssignedContact.Enable(eventContact, currentUser);
            }

            return RedirectToAction("Contacts", "Events",
                new { id = eventContact.Event.Id.Value.ToString() });
        }
开发者ID:ysminnpu,项目名称:OpenLawOffice,代码行数:27,代码来源:EventAssignedContactController.cs

示例4: Create

        public Task Create(ViewModels.TaskViewModel model)
        {
            if (ToadyCount() < 5)
            {
                Task entity = new Task();
                entity.Start = model.Start;

                entity.End = model.Start.AddHours(8);
                entity.EndTimeZone = entity.End.ToString("yyyy-MM-dd");
                entity.StartTimeZone = model.Start.ToString("yyyy-MM-dd");

                //entity.Title = model.Title;
                entity.Description = model.Description;
                entity.MemberID = model.MemberID;
                entity.AddUser = CookieHelper.MemberID;
                entity.AddTime = DateTime.Now;
                if (model.MemberID != CookieHelper.MemberID)
                {
                    entity.IsOtherAdd = true;
                }
                db.Add<Task>(entity);
                db.Commit();
                return entity;
            }
            else
            {
                throw new Exception("当天任务安排不能超过5条");
            }
        }
开发者ID:navy235,项目名称:PadCrm,代码行数:29,代码来源:TaskService.cs

示例5: AssignContact

        public ActionResult AssignContact(ViewModels.Matters.MatterContactViewModel model)
        {
            Common.Models.Account.Users currentUser;
            Common.Models.Matters.MatterContact matterContact;

            // We need to reset the Id of the model as it is picking up the id from the route,
            // which is incorrect
            model.Id = null;

            currentUser = Data.Account.Users.Get(User.Identity.Name);

            matterContact = Data.Matters.MatterContact.Get(model.Matter.Id.Value, model.Contact.Id.Value);

            if (matterContact == null)
            { // Create
                matterContact = Mapper.Map<Common.Models.Matters.MatterContact>(model);
                matterContact = Data.Matters.MatterContact.Create(matterContact, currentUser);
            }
            else
            { // Enable
                matterContact = Mapper.Map<Common.Models.Matters.MatterContact>(model);
                matterContact = Data.Matters.MatterContact.Enable(matterContact, currentUser);
            }

            if (model.Role == "Lead Attorney")
            {
                Common.Models.Matters.Matter matter = Data.Matters.Matter.Get(model.Matter.Id.Value);
                matter.LeadAttorney = Mapper.Map<Common.Models.Contacts.Contact>(model.Contact);
                Data.Matters.Matter.Edit(matter, currentUser);
            }

            return RedirectToAction("Contacts", "Matters",
                new { id = matterContact.Matter.Id.Value.ToString() });
        }
开发者ID:ysminnpu,项目名称:OpenLawOffice,代码行数:34,代码来源:MatterContactController.cs

示例6: Login

        public ActionResult Login(ViewModels.Account.LoginViewModel viewModel, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                if (MembershipService.ValidateUser(viewModel.Username, viewModel.Password))
                {
                    FormsService.SignIn(viewModel.Username, viewModel.RememberMe);
                    if (!string.IsNullOrEmpty(returnUrl))
                    {
                        return Redirect(returnUrl);
                    }
                    else
                    {
                        return RedirectToAction("Index", "Home");
                    }
                }
                else
                {
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                }
            }

            // If we got this far, something failed, redisplay form
            return View(viewModel);
        }
开发者ID:ysminnpu,项目名称:OpenLawOffice,代码行数:25,代码来源:AccountController.cs

示例7: GetReviewCompleted

 void GetReviewCompleted(object s, ViewModels.DoubanSearchCompletedEventArgs args)
 {
     App.SubjectReviewViewModel.GetReviewCompleted -= GetReviewCompleted;
     Deployment.Current.Dispatcher.BeginInvoke(() =>
     {
         if (args.IsSuccess)
         {
             contentContainer.Visibility = Visibility.Visible;
             contentContainer.IsEnabled = false;
             DataContext = args.Result;
             this.SetProgressIndicator(false);
             contentContainer.IsEnabled = true;
             foreach (var content in App.SubjectReviewViewModel.ReveiwContentList)
             {
                 TextBlock tb = new TextBlock();
                 //tb.Width = 445;
                 tb.TextWrapping = TextWrapping.Wrap;
                 tb.Foreground = new SolidColorBrush(Colors.Black);
                 tb.FontSize = (double)App.Current.Resources["PhoneFontSizeMedium"];
                 tb.Text = content;
                 spContent.Children.Add(tb);
             }
             contentContainer.ScrollToVerticalOffset(0);
         }
         else
         {
             ToastPrompt toast = new ToastPrompt();
             toast.Message = args.Message;
             toast.Show();
         }
     });
 }
开发者ID:Hcs66,项目名称:WinDou,代码行数:32,代码来源:SubjectReviewView.xaml.cs

示例8: CalculateWinnings

        public override void CalculateWinnings(ViewModels.CasinoNumberViewModel drawnNumber)
        {
            foreach (var bet in _LastBets)
                CalculateWinningsOnBet(bet, drawnNumber);

            _LastBets.Clear();
        }
开发者ID:pedone,项目名称:CasinoRobot,代码行数:7,代码来源:TendencyBetting.cs

示例9: Configuration

        public ActionResult Configuration(ViewModels.SetupWizard.Configuration model)
        {
            if (ModelState.IsValid)
            {

                try
                {
                    //Tryout the connection string to see if it's valid
                    _dbVersionLogic.CheckDbAccess(model.AzureSQL);

                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("AzureSQL", "Provided connection string is not valid");
                    return View(model);
                }

                //setup database
                _dbVersionLogic.GenerateInitialDatabase(model.AzureSQL);

                var configObj = WebConfigurationManager.OpenWebConfiguration("~");
                var connStringSection = (ConnectionStringsSection)configObj.GetSection("connectionStrings");
                connStringSection.ConnectionStrings["AzureSQL"].ConnectionString = model.AzureSQL;
                var appSettingsSection = (AppSettingsSection)configObj.GetSection("appSettings");
                appSettingsSection.Settings["BaseURL"].Value = model.BaseURL;
                appSettingsSection.Settings["SetupComplete"].Value = "true";
                configObj.Save();

                return RedirectToAction("index", "Home");

            }
            return View(model);
        }
开发者ID:ericdc1,项目名称:whatsforlunch,代码行数:33,代码来源:SetupWizardController.cs

示例10: Create

        public CustomerCompany Create(ViewModels.CustomerCompanyViewModel model)
        {
            CustomerCompany entity = new CustomerCompany();
            entity.Name = model.Name;
            entity.BrandName = model.BrandName;
            entity.IndustryID = Utilities.GetCascadingId(model.IndustryCode);
            entity.IndustryValue = model.IndustryCode;
            entity.CustomerCateID = model.CustomerCateID;
            entity.CityID = Utilities.GetCascadingId(model.CityCode);
            entity.CityValue = model.CityCode;
            entity.Address = model.Address;
            entity.AddTime = DateTime.Now;
            entity.AddUser = CookieHelper.MemberID;
            entity.Description = model.Description;
            entity.Fax = model.Fax;
            entity.LastTime = DateTime.Now;
            entity.LastUser = CookieHelper.MemberID;
            entity.Phone = model.Phone;

            //entity.Finance = model.Finance;
            //entity.FinancePhone = model.FinancePhone;
            entity.ProxyName = model.ProxyName;
            entity.ProxyPhone = model.ProxyPhone;
            entity.ProxyAddress = model.ProxyAddress;
            entity.RelationID = model.RelationID;
            db.Add<CustomerCompany>(entity);
            db.Commit();
            return entity;
        }
开发者ID:navy235,项目名称:PadCrm,代码行数:29,代码来源:CustomerCompanyService.cs

示例11: ChartYearly

        public ActionResult ChartYearly(ViewModels.PmsSummary.ChartViewModel viewModel)
        {
            var artifactDesignerViewModel = new ArtifactDesignerViewModel();
            artifactDesignerViewModel.BarChart = new BarChartViewModel();
            var previewViewModel = new ArtifactPreviewViewModel();
            artifactDesignerViewModel.BarChart.Series.Add(new BarChartViewModel.SeriesViewModel
            {
                KpiId = viewModel.Id,
                Label = "Achievement",
                ValueAxis = ValueAxis.KpiActual.ToString()
            });

             var request = new GetCartesianChartDataRequest();
            request.GraphicName = "Yearly";
            request.GraphicType = "barachievement";
            request.HeaderTitle = "Yearly";
            request.MeasurementId = viewModel.MeasurementId;
            request.PeriodeType = PeriodeType.Yearly;
            request.RangeFilter = RangeFilter.CurrentYear;
            request.ValueAxis = ValueAxis.KpiActual;

            artifactDesignerViewModel.BarChart.MapPropertiesToInstance<GetCartesianChartDataRequest>(request);
            var chartData = _artifactService.GetChartData(request);
            previewViewModel.GraphicType = "barachievement";
            previewViewModel.BarChart = new BarChartDataViewModel();
            previewViewModel.BarChart.Title = "Yearly";
            previewViewModel.BarChart.ValueAxisTitle = _measurementService.GetMeasurement(new GetMeasurementRequest { Id = viewModel.MeasurementId }).Name;
            previewViewModel.BarChart.Series = chartData.Series.MapTo<BarChartDataViewModel.SeriesViewModel>();
            previewViewModel.BarChart.Periodes = chartData.Periodes;
            previewViewModel.BarChart.SeriesType = chartData.SeriesType;
            return Json(previewViewModel, JsonRequestBehavior.AllowGet);
        }
开发者ID:yhsantosa,项目名称:Pear,代码行数:32,代码来源:PmsSummaryController.cs

示例12: Edit

        public ActionResult Edit(int id, ViewModels.Tasks.TaskTemplateViewModel viewModel)
        {
            Common.Models.Account.Users currentUser;
            Common.Models.Tasks.TaskTemplate model;

            using (Data.Transaction trans = Data.Transaction.Create(true))
            {
                try
                {
                    currentUser = Data.Account.Users.Get(trans, User.Identity.Name);

                    model = Mapper.Map<Common.Models.Tasks.TaskTemplate>(viewModel);

                    model = Data.Tasks.TaskTemplate.Edit(trans, model, currentUser);

                    trans.Commit();

                    return RedirectToAction("Details", new { Id = id });
                }
                catch
                {
                    trans.Rollback();
                    return Edit(id);
                }
            }
        }
开发者ID:NodineLegal,项目名称:OpenLawOffice.Web,代码行数:26,代码来源:TaskTemplatesController.cs

示例13: MatterContactAssignment

        private void MatterContactAssignment(
            ViewModels.Matters.MatterContactViewModel viewModel, 
            Common.Models.Matters.Matter matter,
            Common.Models.Account.Users currentUser, 
            Data.Transaction trans)
        {
            if (viewModel != null && viewModel.Contact != null
                && viewModel.Contact.Id.HasValue)
            {
                Common.Models.Matters.MatterContact mcOld;

                mcOld = Data.Matters.MatterContact.Get(matter.Id.Value, viewModel.Contact.Id.Value);

                if (mcOld == null)
                { // Create
                    Common.Models.Matters.MatterContact mcNew;
                    mcNew = Mapper.Map<Common.Models.Matters.MatterContact>(viewModel);
                    mcNew.Matter = matter;
                    mcNew = Data.Matters.MatterContact.Create(trans, mcNew, currentUser);
                }
                else
                { // Enable
                    Common.Models.Matters.MatterContact mcNew;
                    mcNew = Mapper.Map<Common.Models.Matters.MatterContact>(viewModel);
                    mcNew.Matter = matter;
                    mcNew.Id = mcOld.Id;
                    mcNew = Data.Matters.MatterContact.Enable(trans, mcNew, currentUser);
                    mcNew = Data.Matters.MatterContact.Edit(trans, mcNew, currentUser);
                }
            }
        }
开发者ID:NodineLegal,项目名称:OpenLawOffice.Web,代码行数:31,代码来源:MatterContactController.cs

示例14: Create

 public Customer Create(ViewModels.CustomerViewModel model)
 {
     Customer entity = new Customer();
     entity.Name = model.Name;
     entity.Address = model.Address;
     entity.AddTime = DateTime.Now;
     entity.AddUser = CookieHelper.MemberID;
     entity.ReMark = model.ReMark;
     entity.IsLeap = model.IsLeap;
     if (entity.IsLeap)
     {
         entity.BirthDay1 = Utilities.GetLunarStringOnlyMonthDay(model.BirthDay);
     }
     entity.BirthDay = model.BirthDay;
     entity.CompanyID = model.CompanyID;
     entity.Email = model.Email;
     entity.Favorite = model.Favorite;
     entity.JobID = model.JobID;
     entity.Jobs = model.Jobs;
     entity.LastTime = DateTime.Now;
     entity.LastUser = 1;
     entity.Mobile = model.Mobile;
     entity.Mobile1 = model.Mobile1;
     entity.Phone = model.Phone;
     entity.QQ = model.QQ;
     db.Add<Customer>(entity);
     db.Commit();
     return entity;
 }
开发者ID:navy235,项目名称:PadCrm,代码行数:29,代码来源:CustomerService.cs

示例15: LogOnServerDialog

        public LogOnServerDialog(ViewModels.LogonServerViewModel viewModel)
        {
            InitializeComponent();

            this.DataContext = viewModel;
            viewModel.CurrentWindow = this;
        }
开发者ID:fenglinz,项目名称:Sparrow,代码行数:7,代码来源:LogOnServerDialog.xaml.cs


注:本文中的ViewModels类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。