Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        private bool updatefromsource(String id)
        {
            string        cuurentsession = "";
            string        currentsession = dbcontext.Configs.First(p => p.ConfigName == "CurrentSession").ConfigValue;
            StudentPerson sp             = getStudentPersonFromSouce(id, currentsession);

            if (!dbcontext.StudentPersons.Any(p => p.Person.IdentityNo == id))
            {
                IdentityDataLayer.DataModels.Person ip = new IdentityDataLayer.DataModels.Person();
                ip.IdentityNo     = sp.PersonID;
                ip.Surname        = sp.Surname;
                ip.Firstname      = sp.Firstname;
                ip.Middlename     = sp.Middlename;
                ip.Phone          = sp.Phone;
                ip.Email          = sp.Email;
                ip.Address        = sp.Address;
                ip.HealthCentreNo = sp.HCN;
                ip.Sex            = sp.Sex.ToString();
                dbcontext.Persons.Add(ip);
                // dbcontext.SaveChanges();
                // dbcontext = new IdentityDataLayer.DataModels.IdentityDBEntities();
                // ip = dbcontext.Persons.Single(p => p.IdentityNo == sp.PersonID);
                IdentityDataLayer.DataModels.StudentPerson isp = new IdentityDataLayer.DataModels.StudentPerson();
                isp.CurrentLevel        = sp.Level;
                isp.Program             = sp.Programme;
                isp.SponsorName         = sp.SponsorName;
                isp.SponsorPhone        = sp.SponsorPhone;
                isp.SponsorAddress      = sp.SponsorAddress;
                isp.StudentCategoryId   = sp.CategoryId;
                isp.CurrentDepartmentId = dbcontext.Departments.First(p => p.DepartmentCode == sp.Department.Code).DepartmentId;
                isp.CreatedBy           = 1;
                isp.DateCreated         = DateTime.Now;
                isp.Person = ip;
                isp.LastEnrollmentSession = sp.CurrentSession;
                isp.LastEnrollmentStatus  = sp.CurrentStatus;
                dbcontext.StudentPersons.Add(isp);
                dbcontext.SaveChanges();
            }
            else
            {
                IdentityDataLayer.DataModels.StudentPerson isp = dbcontext.StudentPersons.First(p => p.Person.IdentityNo == id);
                if (!match(sp, isp))
                {
                    bool b = saveStudentPersonProfile(id, sp, null);
                    return(b);
                }
            }
            dbcontext = new IdentityDataLayer.DataModels.IdentityDBEntities();
            return(true);
        }
Esempio n. 5
0
 public PersonRepository()
 {
     dbcontext = new IdentityDataLayer.DataModels.IdentityDBEntities();
 }