I must preface this with I'm very new to viewmodels. That being said, I want to have a create view with payment and subscription info, like a paytment registration page. I want to update multiple entities in my EF model and I was planning on doing it via a viewmodel. The problem is when I try to create view based on my controller action.. i get this error:
My viewmodel is used a standalone class to get/post data to my view... maybe I'm going about this the wrong way.. does it have to have a primary key? Does it need to be in my db and added as an EF entity? How do i fix this? Thanks
Here is viewmodel code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MVCProject.DataAccess;
using System.ComponentModel.DataAnnotations;
namespace MVCProject.Models.ViewModel
{
public class PaymentSetupViewModel
{
//Subscription.cs
[Required(ErrorMessage = "required")]
public string Frequency { get; set; }
public DateTime Date { get; set; }
//PaymentMethod.cs
[Required(ErrorMessage = "required")]
[CreditCard]
[Display(Name = "Card Number")]
public string CCNumber { get; set; }
[Required(ErrorMessage = "required")]
[Display(Name = "Card Expiration")]
public DateTime CCExpiration { get; set; }
[Required(ErrorMessage = "required")]
[Display(Name = "CVV2")]
public string CCCVV2 { get; set; }
[Required(ErrorMessage = "required")]
[Display(Name = "Bank Name")]
public string BankName { get; set; }
[Required(ErrorMessage = "required")]
[Display(Name = "Account Number")]
public string BankAccountNumber { get; set; }
[Required(ErrorMessage = "required")]
[Display(Name = "Routing Number")]
public string BankRoutingNumber { get; set; }
[Required(ErrorMessage = "required")]
public string ProductName { get; set; }
//AspNetUser.cs properties -- identity list of logins
public string UserName { get; set; }
//PaymentSubscriptionViewModels.cs properties
public int SelectedValue { get; set; }
}
}