public string SaveOtherFilesUploadData(List <PilotDocumentMasterViewModel> Model) { string Massage = ""; try { int DocId = _context.DocumentMasters.Where(d => d.IsActive && d.DocumentName == "Other").FirstOrDefault().Id; if (DocId > 0) { foreach (var item in Model) { ptaDocumentDetail info = new ptaDocumentDetail { DocumentMasterId = DocId, DocumentPath = item.DocumentPath, IsActive = true, Extention = item.Extention, ptaPilotRegistrationMasterId = item.ptaPilotRegistrationMasterId, ptaAdmissionMasterId = item.PilotAdmissionId, EnteredStudentBy = item.EnteredStudentBy, EnteredDate = DateTime.Now }; _context.ptaDocumentDetails.Add(info); } _context.SaveChanges(); Massage = "Medical document successfully uploaded."; } return(Massage); } catch (Exception ex) { return(ex.Message); } }
//*******************Upload Docs(17/03/20)**************// public string SaveMedicalUploadFiles(List <PilotDocumentMasterViewModel> Model) { string Massage = ""; try { foreach (var item in Model) { var data = _context.ptaDocumentDetails.Where(p => p.IsActive && p.ptaPilotRegistrationMasterId == item.Id && p.DocumentMasterId == item.DocumentMasterId).FirstOrDefault(); if (data != null && string.IsNullOrEmpty(item.IsPreviousExist)) { data.DocumentPath = item.DocumentPath; data.Extention = item.Extention; data.UpdatedDate = DateTime.Now; data.UpdatedStudentBy = item.UpdatedStudentBy; } else { if (item.EnteredStudentBy > 0) { var ad = _context.ptaAdmissionMasters.Where(p => p.ptaRegistrationInfoes.FirstOrDefault().ptaPilotRegistrationMasterId == item.ptaPilotRegistrationMasterId).FirstOrDefault(); if (ad != null) { ptaDocumentDetail info = new ptaDocumentDetail { DocumentMasterId = item.DocumentMasterId, DocumentPath = item.DocumentPath, IsActive = true, Extention = item.Extention, ptaPilotRegistrationMasterId = item.ptaPilotRegistrationMasterId, ptaAdmissionMasterId = ad.Id, EnteredDate = DateTime.Now, EnteredStudentBy = item.EnteredStudentBy }; _context.ptaDocumentDetails.Add(info); } } } } _context.SaveChanges(); Massage = "Medical document successfully uploaded."; return(Massage); } catch (Exception ex) { return(ex.Message); } }