Я работаю над созданием веб-приложения для Управления больницей, в котором администратор должен подтвердить регистрацию пациента / врача. Я создал таблицу регистрации и установил для каждой записи статус 0, пока администратор не одобрит ее. Я хочу изменить столбец на 1, когда администратор одобрит регистрацию. Я написал одобренное представление, и как только администратор щелкнет его, 0 должно измениться на 1. Но я получаю сообщение об ошибке проверки.
Прикрепление моего кода
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");
и файл Table.cs
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; }
}
}
Ошибка: