public bool saveFingerPrint(Dictionary <int, string> Fmds, Dictionary <int, List <string> > Fids, string personIdNo, int?snapshotid) { if (snapshotid == null) { IdentityDataLayer.DataModels.IDSnapshot idsnapshot = new IdentityDataLayer.DataModels.IDSnapshot(); idsnapshot.SnapshotDetails = ""; IdentityDataLayer.DataModels.Person person = dbcontext.Persons.First(p => p.IdentityNo == personIdNo); idsnapshot.PersonId = person.Id; idsnapshot.CreatedBy = 1; idsnapshot.DateCreated = DateTime.Now; dbcontext.IDSnapshots.Add(idsnapshot); foreach (int finger in Fmds.Keys) { IdentityDataLayer.DataModels.PersonFinger pf = new IdentityDataLayer.DataModels.PersonFinger(); pf.IDSnapshot = idsnapshot; pf.FingerId = finger; pf.FMD = Fmds[finger]; pf.CreatedBy = 1; List <string> fds = Fids[finger]; pf.FID1 = fds[0]; pf.FID2 = fds[1]; pf.FID3 = fds[2]; pf.FID4 = fds[3]; pf.DateCreated = DateTime.Now; dbcontext.PersonFingers.Add(pf); } dbcontext.SaveChanges(); } dbcontext = new IdentityDataLayer.DataModels.IdentityDBEntities(); return(true); }
public bool saveStudentPersonProfile(string personIdNo, StudentPerson newpersonprofile, int?snapshotid, bool overridewithnull = true) { //backup old data if (dbcontext.Persons.Any(p => p.IdentityNo == personIdNo)) { IdentityDataLayer.DataModels.StudentPerson pid = dbcontext.StudentPersons.First(p => p.Person.IdentityNo == personIdNo); if (!dbcontext.IDSnapshots.Any(p => p.PersonId == pid.Person.Id && p.SnapshotDetails != "")) { //back migrated data IdentityDataLayer.DataModels.IDSnapshot idsnapshot = new IdentityDataLayer.DataModels.IDSnapshot(); idsnapshot.SnapshotDetails = serializeXML(pid); idsnapshot.PersonId = pid.PersonId; idsnapshot.CreatedBy = 1; idsnapshot.DateCreated = DateTime.Now.AddDays(-1); dbcontext.IDSnapshots.Add(idsnapshot); dbcontext.SaveChanges(); } } if (snapshotid == null) { IdentityDataLayer.DataModels.IDSnapshot idsnapshot = new IdentityDataLayer.DataModels.IDSnapshot(); idsnapshot.SnapshotDetails = serializeXML(newpersonprofile); IdentityDataLayer.DataModels.Person person = dbcontext.Persons.First(p => p.IdentityNo == personIdNo); idsnapshot.PersonId = person.Id; idsnapshot.CreatedBy = 1; idsnapshot.DateCreated = DateTime.Now; dbcontext.IDSnapshots.Add(idsnapshot); person.Surname = newpersonprofile.Surname; person.Firstname = newpersonprofile.Firstname; person.Middlename = newpersonprofile.Middlename; person.HealthCentreNo = newpersonprofile.HCN ?? person.HealthCentreNo; person.BloodGroup = newpersonprofile.BG ?? person.BloodGroup; person.StudentPerson.CurrentLevel = String.IsNullOrEmpty(newpersonprofile.Level)? person.StudentPerson.CurrentLevel: newpersonprofile.Level; person.StudentPerson.StudentCategoryId = newpersonprofile.CategoryId; // String.IsNullOrEmpty(newpersonprofile.Level) ? person.StudentPerson.CurrentLevel : newpersonprofile.Level; /* if (newpersonprofile.CategoryId == 2) * { * person.StudentPerson.Program = newpersonprofile.Level; * * }*/ person.StudentPerson.Program = newpersonprofile.Programme; person.Phone = newpersonprofile.Phone ?? person.Phone; person.Email = newpersonprofile.Email ?? person.Email; person.Sex = newpersonprofile.Sex.ToString(); person.StudentPerson.SponsorName = newpersonprofile.SponsorName ?? person.StudentPerson.SponsorName; person.StudentPerson.SponsorAddress = newpersonprofile.SponsorAddress ?? person.StudentPerson.SponsorAddress; person.StudentPerson.SponsorPhone = newpersonprofile.SponsorPhone ?? person.StudentPerson.SponsorPhone; person.StudentPerson.CurrentDepartmentId = newpersonprofile.Department.Code == null? person.StudentPerson.CurrentDepartmentId:dbcontext.Departments.First(p => p.DepartmentCode == newpersonprofile.Department.Code).DepartmentId; person.StudentPerson.LastEnrollmentSession = String.IsNullOrEmpty(newpersonprofile.CurrentSession)? person.StudentPerson.LastEnrollmentSession : newpersonprofile.CurrentSession; person.StudentPerson.LastEnrollmentStatus = String.IsNullOrEmpty(newpersonprofile.CurrentStatus)? person.StudentPerson.LastEnrollmentStatus:newpersonprofile.CurrentStatus; dbcontext.SaveChanges(); } dbcontext = new IdentityDataLayer.DataModels.IdentityDBEntities(); return(true); }
public bool savePersonPic(byte[] photo, string personIdNo, int?snapshotid) { //backup old data if (dbcontext.Persons.Any(p => p.IdentityNo == personIdNo && p.CurrentPhoto != null)) { IdentityDataLayer.DataModels.Person pid = dbcontext.Persons.First(p => p.IdentityNo == personIdNo && p.CurrentPhoto != null); if (!dbcontext.PersonPictures.Any(p => p.IDSnapshot.PersonId == pid.Id && p.OriginalImage != null)) { //back migrated data IdentityDataLayer.DataModels.IDSnapshot idsnapshot = new IdentityDataLayer.DataModels.IDSnapshot(); idsnapshot.SnapshotDetails = ""; idsnapshot.PersonId = pid.Id; idsnapshot.CreatedBy = 1; idsnapshot.DateCreated = DateTime.Now.AddDays(-1); dbcontext.IDSnapshots.Add(idsnapshot); IdentityDataLayer.DataModels.PersonPicture pc = new IdentityDataLayer.DataModels.PersonPicture(); pc.IDSnapshot = idsnapshot; pc.ProcessedImage = pid.WatermarkedPhoto; pc.OriginalImage = pid.CurrentPhoto; pc.CreatedBy = 1; pc.DateCreated = DateTime.Now.AddDays(-1);; dbcontext.PersonPictures.Add(pc); dbcontext.SaveChanges(); } } if (snapshotid == null) { IdentityDataLayer.DataModels.IDSnapshot idsnapshot = new IdentityDataLayer.DataModels.IDSnapshot(); idsnapshot.SnapshotDetails = ""; IdentityDataLayer.DataModels.Person person = dbcontext.Persons.First(p => p.IdentityNo == personIdNo); idsnapshot.PersonId = person.Id; idsnapshot.CreatedBy = 1; idsnapshot.DateCreated = DateTime.Now; dbcontext.IDSnapshots.Add(idsnapshot); IdentityDataLayer.DataModels.PersonPicture pc = new IdentityDataLayer.DataModels.PersonPicture(); pc.IDSnapshot = idsnapshot; pc.ProcessedImage = photo; pc.OriginalImage = photo; pc.CreatedBy = 1; pc.DateCreated = DateTime.Now; dbcontext.PersonPictures.Add(pc); person.CurrentPhoto = photo; //watermaked picture; MemoryStream ms = new MemoryStream(photo, 0, photo.Length, true, true); byte [] bytes = Util.AddWaterMark(ms, "FUNAAB"); person.WatermarkedPhoto = bytes; dbcontext.SaveChanges(); } dbcontext = new IdentityDataLayer.DataModels.IdentityDBEntities(); return(true); }