public MedicalFilesMV openPatientCreate(MedicalFilesMV model = null)
        {
            LookupBussiness look = new LookupBussiness();

            if (model == null)
            {
                model = new MedicalFilesMV();
            }



            model.patientlist = look.fillpatient();


            return(model);
        }
        public ResponseMV createnewpatientmedicalfile(MedicalFilesMV newfile)
        {
            ResponseMV result = ValidateMedicalFile(newfile);

            if (result.IsValid == true)
            {
                MedicalFileTBL filetemp = new MedicalFileTBL();
                filetemp.id          = newfile.id;
                filetemp.FileSerial  = newfile.FileSerial;
                filetemp.patientid   = newfile.patientid;
                filetemp.Discraption = newfile.Discraption;
                clinic.MedicalFileTBLs.Add(filetemp);
                clinic.SaveChanges();
            }
            return(result);
        }
        public ActionResult Createnewfile(MedicalFilesMV filenew)

        {
            ResponseMV result = file.createnewpatientmedicalfile(filenew);

            if (result.IsValid == true)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                foreach (var item in result.ErrorMessages)
                {
                    ModelState.AddModelError(item.Key, item.Value);
                }
                filenew = file.openPatientCreate(filenew);
                return(View("Create", filenew));
            }
        }
        public ResponseMV ValidateMedicalFile(MedicalFilesMV viewmodel)
        {
            MedicalFilesMV res    = Selectfilepatient((int)viewmodel.patientid);
            ResponseMV     result = new ResponseMV();

            if (string.IsNullOrEmpty(viewmodel.FileSerial))
            {
                result.ErrorMessages.Add("FileSerial", "not found name");
            }
            if (viewmodel.patientid == null)
            {
                result.ErrorMessages.Add("patientname", "not found name");
            }
            if (res != null)
            {
                result.ErrorMessages.Add("patientname2", "has medical file");
            }



            result.IsValid = result.ErrorMessages.Count == 0 ? true : false;
            return(result);
        }
        // GET: MedicalFile/Create
        public ActionResult Create()
        {
            MedicalFilesMV newfileopen = file.openPatientCreate();

            return(View(newfileopen));
        }