Click here to Skip to main content
15,887,895 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionRe Getting_Error Pin
Member 1116162527-Feb-15 17:20
Member 1116162527-Feb-15 17:20 
AnswerRe: Re Getting_Error Pin
Pete O'Hanlon27-Feb-15 21:51
mvePete O'Hanlon27-Feb-15 21:51 
QuestionGetting_Error Pin
Member 1116162526-Feb-15 19:26
Member 1116162526-Feb-15 19:26 
AnswerRe: Getting_Error Pin
Pete O'Hanlon26-Feb-15 20:18
mvePete O'Hanlon26-Feb-15 20:18 
QuestionError Pin
Member 1116162526-Feb-15 18:31
Member 1116162526-Feb-15 18:31 
SuggestionRe: Error Pin
Richard MacCutchan26-Feb-15 21:25
mveRichard MacCutchan26-Feb-15 21:25 
QuestionAccessing Telerik DropDownColumn from EditedTemplate Pin
byka25-Feb-15 7:21
byka25-Feb-15 7:21 
QuestionThe model item passed into the dictionary is of type 'WebTime_Sheet.Models.RegisterViewModel', but this dictionary requires a model item of type 'WebTime_Sheet.Models.Users'. Pin
Kriss Legrand23-Feb-15 16:23
Kriss Legrand23-Feb-15 16:23 
PLEASE HELP ME NOW. I must submit my project tomorrow
For 2 weeks i haven't made a successful save. what is wrong with my codes? i have this error:

The model item passed into the dictionary is of type 'WebTime_Sheet.Models.RegisterViewModel', but this dictionary requires a model item of type 'WebTime_Sheet.Models.Users'.


The Action Results
//
       // GET: /Account/Register
       [AllowAnonymous]
       public ActionResult Register()
       {
           ViewBag.RoleName = new SelectList(db.Roles, "RoleName", "RoleName");
           return View();
       }

       //
       // POST: /Account/Register
       [HttpPost]
       [AllowAnonymous]
       [ValidateAntiForgeryToken]
       public async Task<ActionResult> Register(RegisterViewModel model, DateTime? EmploymentEndDate = null)
       {
           if (ModelState.IsValid)
           {
               var user = new ApplicationUser {
                   UserName = model.Email,
                   Email = model.Email };
               var result = await UserManager.CreateAsync(user, model.Password);
               if (result.Succeeded)
               {
                   using (var context = new TimeSheetsEntities())
                   {
                       var u = new Users
                       {
                           UserId = model.UserId,
                           SocialSecurityNumber = model.SocialSecurityNumber,
                           FirstName = model.FirstName,
                           LastName = model.LastName,
                           Address1 = model.Address1,
                           ZipCode = model.ZipCode,
                           City = model.City,
                           PhoneNumber1 = model.PhoneNumber1,
                           PhoneNumber2 = model.PhoneNumber2,
                           EmploymentStartDate = model.EmploymentStartDate,
                           EmploymentEndDate = model.EmploymentEndDate,
                           Email = model.Email,
                           Password = model.Password,
                           RoleName = model.RoleName,
                       };
                       context.Users.Add(u);
                       context.SaveChanges();
                   }
                   await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);

                   // 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.GenerateEmailConfirmationTokenAsync(user.Id);
                   // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                   // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                   return RedirectToAction("Index", "Home");
               }
               AddErrors(result);
           }

           // If we got this far, something failed, redisplay form
           return View(model);
       }


Then the class...
SQL
public class RegisterViewModel
{
    [Required]
    [Range(10000 - 99999, Double.MaxValue, ErrorMessage = "Create 5 digit UserId")]
    [Display(Name = "User Identification")]
    public int UserId { get; set; }

    [Required]
    [Display(Name = "Social Security number")]
    public string SocialSecurityNumber { get; set; }

    [Required]
    [Display(Name = "Firstname")]
    public string FirstName { get; set; }

    [Required]
    [Display(Name = "Lastname")]
    public string LastName { get; set; }

    [Required]
    [Display(Name = "Adress Line 1")]
    public string Address1 { get; set; }

    [Required]
    [Display(Name = "Adress Line 2")]
    public string Address2 { get; set; }

    [Required]
    [Display(Name = "Postal code")]
    public string ZipCode { get; set; }

    [Required]
    [Display(Name = "City")]
    public string City { get; set; }

    [Required]
    [Display(Name = "Telephone number")]
    public string PhoneNumber1 { get; set; }
    [Required]
    [Display(Name = "Telephon number")]
    public string PhoneNumber2 { get; set; }

    [Required]
    [Display(Name = "Date of employment")]
    public DateTime EmploymentStartDate { get; set; }

    [Required]
    [Display(Name = "End of Employment")]
    public DateTime? EmploymentEndDate { get; set; }

    [Required]
    [EmailAddress]
    [Display(Name = "Email")]
    public string Email { get; set; }

    [Required]
    [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
    [DataType(DataType.Password)]
    [Display(Name = "Password")]
    public string Password { get; set; }

    [DataType(DataType.Password)]
    [Display(Name = "Confirm password")]
    [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
    public string ConfirmPassword { get; set; }

    [Required]
    [Display(Name = "Role")]
    public string RoleName { get; set; }

AnswerRe: The model item passed into the dictionary is of type 'WebTime_Sheet.Models.RegisterViewModel', but this dictionary requires a model item of type 'WebTime_Sheet.Models.Users'. Pin
Dave Kreskowiak23-Feb-15 17:30
mveDave Kreskowiak23-Feb-15 17:30 
GeneralRe: The model item passed into the dictionary is of type 'WebTime_Sheet.Models.RegisterViewModel', but this dictionary requires a model item of type 'WebTime_Sheet.Models.Users'. Pin
Kriss Legrand23-Feb-15 21:22
Kriss Legrand23-Feb-15 21:22 
GeneralRe: The model item passed into the dictionary is of type 'WebTime_Sheet.Models.RegisterViewModel', but this dictionary requires a model item of type 'WebTime_Sheet.Models.Users'. Pin
Dave Kreskowiak24-Feb-15 2:34
mveDave Kreskowiak24-Feb-15 2:34 
QuestionService Broker Pin
Member 1116162520-Feb-15 17:18
Member 1116162520-Feb-15 17:18 
AnswerRe: Service Broker Pin
Dave Kreskowiak20-Feb-15 17:58
mveDave Kreskowiak20-Feb-15 17:58 
Questionnested datalist not updating on databinding Pin
ankita prabha18-Feb-15 23:38
ankita prabha18-Feb-15 23:38 
QuestionExtract certain Text FROM PDF into my vb.NET TextBoxes Pin
VIERcntHOLZ11-Feb-15 5:21
VIERcntHOLZ11-Feb-15 5:21 
AnswerRe: Extract certain Text FROM PDF into my vb.NET TextBoxes Pin
Richard MacCutchan11-Feb-15 5:37
mveRichard MacCutchan11-Feb-15 5:37 
GeneralRe: Extract certain Text FROM PDF into my vb.NET TextBoxes Pin
VIERcntHOLZ11-Feb-15 5:46
VIERcntHOLZ11-Feb-15 5:46 
GeneralRe: Extract certain Text FROM PDF into my vb.NET TextBoxes Pin
Richard MacCutchan11-Feb-15 6:48
mveRichard MacCutchan11-Feb-15 6:48 
GeneralRe: Extract certain Text FROM PDF into my vb.NET TextBoxes Pin
VIERcntHOLZ12-Feb-15 5:45
VIERcntHOLZ12-Feb-15 5:45 
GeneralRe: Extract certain Text FROM PDF into my vb.NET TextBoxes Pin
manchanx12-Feb-15 13:32
professionalmanchanx12-Feb-15 13:32 
GeneralRe: Extract certain Text FROM PDF into my vb.NET TextBoxes Pin
Richard MacCutchan12-Feb-15 22:29
mveRichard MacCutchan12-Feb-15 22:29 
QuestionRANKING IN VB.NET MYSQL Pin
KipkoechE11-Feb-15 1:30
KipkoechE11-Feb-15 1:30 
AnswerRe: RANKING IN VB.NET MYSQL Pin
Richard MacCutchan11-Feb-15 1:39
mveRichard MacCutchan11-Feb-15 1:39 
QuestionDATAGRIDVIEW VB.NET Pin
KipkoechE8-Feb-15 17:21
KipkoechE8-Feb-15 17:21 
QuestionRe: DATAGRIDVIEW VB.NET Pin
Eddy Vluggen10-Feb-15 11:28
professionalEddy Vluggen10-Feb-15 11:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.