I am working on creating a web application for Hospital Management where admin need to approve the Patient/Doctor registration. I have created registration table and set status for each record to 0 until admin approves it. I want to change the column to 1 when admin approves the registration. I have written the approve view and once admin click it 0 should change to 1. But I am getting the validation error.
Attaching my code
using AgileProject_DMC.Models;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.DynamicData;
using System.Web.Mvc;
namespace AgileProject_DMC.Controllers
{
public class AdminApproveController : Controller
{
// GET: AdminApproving
public ActionResult PatientDetails()
{
using(RegistrationEntities6 dbModel =new RegistrationEntities6() )
{
return View(dbModel.PatientRegistrationTables.Where(x => x.IsStatus==0).ToList());
}
return View();
}
public ActionResult PatientApprove(int id)
{
RegistrationEntities6 contextObject = new RegistrationEntities6();
//contextObject.Database.ExecuteSqlCommand("Update PatientRegistrationTable SET IsStatus = 1 Where PatientId={0 }", id);
var acceptStatus = contextObject.PatientRegistrationTables.Find(id);
acceptStatus.IsStatus = 1;
contextObject.SaveChanges();
return RedirectToAction("PatientDetails");
and Table.cs file is
namespace AgileProject_DMC.Models
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
public partial class PatientRegistrationTable
{
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public int PatientId { get; set; }
[DisplayName("First Name")]
[Required(AllowEmptyStrings = false, ErrorMessage = "This field is required")]
public string FirstName { get; set; }
[DisplayName("Last Name")]
[Required(AllowEmptyStrings = false, ErrorMessage = "This field is required")]
public string LastName { get; set; }
[Required(ErrorMessage = "This field is required")]
public Nullable<int> Age { get; set; }
[Required(ErrorMessage = "This field is required")]
public string Gender { get; set; }
[Required(ErrorMessage = "This field is required")]
[DisplayName("Contact Number")]
public Nullable<long> ContactNumber { get; set; }
[DisplayName("User Name")]
[Required(AllowEmptyStrings = false, ErrorMessage = "This field is required")]
public string UserName { get; set; }
[DataType(DataType.Password)]
[Required(AllowEmptyStrings = false, ErrorMessage = "Password is required")]
[MinLength(6, ErrorMessage = "Minimum 6 characters required")]
public string Password { get; set; }
[DataType(DataType.Password)]
[DisplayName("Confirm Password")]
[Compare("Password")]
public string ConfirmPassword { get; set; }
public Nullable<int> IsStatus { get; set; }
public string LoginErrorMessage { get; set; }
}
}
Error is: