Esempio n. 1
0
        public string Save(UserModel model)
        {
            ResultHelper _resultHelper = new ResultHelper();

            using (var db = new nasccoEntities())
            {
                using (DbContextTransaction dbTran = db.Database.BeginTransaction())
                {
                    try
                    {
                        var data = db.users.Create();
                        data.member_id          = model.UserMemberId;
                        data.roles_id           = model.RolesId;
                        data.statuses_id        = model.UserStatusesId;
                        data.username           = model.Username;
                        data.password           = EncryptDecryptString.Encrypt(model.Password);
                        data.date_created       = DateTime.Now;
                        data.created_by_user_id = model.CreatedByUserId;
                        db.users.Add(data);
                        db.SaveChanges();

                        //Save if no issues
                        dbTran.Commit();
                        return(_resultHelper.Success());
                    }
                    catch (Exception ex)
                    {
                        dbTran.Rollback();
                        return(ex.Message);
                    }
                }
            }
        }
Esempio n. 2
0
        public string RemoveUser(int id)
        {
            ResultHelper _resultHelper = new ResultHelper();

            using (var db = new nasccoEntities())
            {
                using (DbContextTransaction dbTran = db.Database.BeginTransaction())
                {
                    try
                    {
                        var record = (from x in db.users
                                      where x.id == id
                                      select x).FirstOrDefault();
                        db.users.Remove(record);
                        db.SaveChanges();



                        dbTran.Commit();
                        return(_resultHelper.Success());
                    }
                    catch (Exception ex)
                    {
                        dbTran.Rollback();
                        return(ex.Message);
                    }
                }
            }
        }
Esempio n. 3
0
        public string UpdateSpouse(SpouseModel model)
        {
            ResultHelper _resultHelper = new ResultHelper();

            using (var db = new nasccoEntities())
            {
                try
                {
                    var data = db.spouses.FirstOrDefault(x => x.id == model.SpouseId);

                    data.lastname          = model.SpouseLastName;
                    data.firstname         = model.SpouseFirstName;
                    data.middlename        = model.SpouseMiddleName;
                    data.date_of_birth     = model.SpouseDateOfBirth;
                    data.occupation        = model.SpouseOccupation;
                    data.employer          = model.SpouseEmployer;
                    data.employer_address  = model.SpouseEmployerAddress;
                    data.employer_contact  = model.SpouseEmployerContact;
                    data.monthly_income    = model.SpouseMonthlyIncome;
                    data.contact_numbers   = model.SpouseContactNumber;
                    data.employment_status = model.SpouseEmploymentStatus;
                    db.SaveChanges();
                    return(_resultHelper.Success());
                }
                catch (Exception ex)
                {
                    return(ex.Message);
                }
            }
        }
Esempio n. 4
0
        public string ChangePassword(UserModel model)
        {
            ResultHelper _resultHelper = new ResultHelper();

            using (var db = new nasccoEntities())
            {
                using (DbContextTransaction dbTran = db.Database.BeginTransaction())
                {
                    try
                    {
                        var data = db.users.FirstOrDefault(x => x.id == model.UserId);
                        data.password = EncryptDecryptString.Encrypt(model.Password);
                        db.SaveChanges();

                        //Save if no issues
                        dbTran.Commit();
                        return(_resultHelper.Success());
                    }
                    catch (Exception ex)
                    {
                        dbTran.Rollback();
                        return(ex.Message);
                    }
                }
            }
        }
Esempio n. 5
0
        public string SaveReferences(ReferencesModel model)
        {
            ResultHelper _resultHelper = new ResultHelper();

            using (var db = new nasccoEntities())
            {
                using (DbContextTransaction dbTran = db.Database.BeginTransaction())
                {
                    try
                    {
                        var data = db.references.Create();
                        data.full_name          = model.ReferencesFullName;
                        data.relation           = model.ReferencesRelation;
                        data.address            = model.ReferencesAddress;
                        data.contact_number     = model.ReferencesContactNumber;
                        data.member_id          = model.ReferencesMemberId;
                        data.created_by_user_id = model.ReferencesCreatedByUserId;
                        data.date_created       = DateTime.Now;

                        db.references.Add(data);
                        db.SaveChanges();

                        //Save if no issues
                        dbTran.Commit();
                        return(_resultHelper.Success());
                    }
                    catch (Exception ex)
                    {
                        dbTran.Rollback();
                        return(ex.Message);
                    }
                }
            }
        }
Esempio n. 6
0
        public string SaveMember(MemberModel model)
        {
            ResultHelper _resultHelper = new ResultHelper();

            using (var db = new nasccoEntities())
            {
                using (DbContextTransaction dbTran = db.Database.BeginTransaction())
                {
                    try
                    {
                        var data = db.members.Create();
                        data.pmes_certificate_number = model.PmesCertificateNumber;
                        data.date_of_application     = model.DateOfApplication;
                        data.lastname                       = model.LastName;
                        data.firstname                      = model.LastName;
                        data.middlename                     = model.MiddleName;
                        data.date_of_birth                  = model.DateOfBirth;
                        data.place_of_birth                 = model.PlaceOfBirth;
                        data.height                         = model.Heigth;
                        data.weight                         = model.Weight;
                        data.tin                            = model.Tin;
                        data.sss_number                     = model.SssNumber;
                        data.others_id                      = model.OthersId;
                        data.weight                         = model.Weight;
                        data.tin                            = model.Tin;
                        data.highest_education              = model.HighestEducation;
                        data.course                         = model.Course;
                        data.present_address                = model.PresentAddress;
                        data.address_status                 = model.AddressStatus;
                        data.provincial_address             = model.ProvincialAddress;
                        data.present_address_lenght_of_time = model.PresentAddressLengthOfTime;
                        data.contact_numbers                = model.ContactNumbers;
                        data.email_address                  = model.EmailAddress;
                        data.statuses_id                    = model.StatusesId;
                        data.employee_id                    = model.EmployeeId;
                        data.created_by_user_id             = model.CreatedByUserId;


                        db.members.Add(data);
                        db.SaveChanges();

                        //Save if no issues
                        dbTran.Commit();
                        return(_resultHelper.Success());
                    }
                    catch (Exception ex)
                    {
                        dbTran.Rollback();
                        return(ex.Message);
                    }
                }
            }
        }
Esempio n. 7
0
        public string Update(MemberModel model)
        {
            ResultHelper _resultHelper = new ResultHelper();

            using (var db = new nasccoEntities())
            {
                try
                {
                    var data = db.members.FirstOrDefault(x => x.id == model.MemberId);
                    data.pmes_certificate_number = model.PmesCertificateNumber;
                    data.date_of_application     = model.DateOfApplication;
                    data.lastname                       = model.LastName;
                    data.firstname                      = model.FirstName;
                    data.middlename                     = model.MiddleName;
                    data.date_of_birth                  = model.DateOfBirth;
                    data.place_of_birth                 = model.PlaceOfBirth;
                    data.height                         = model.Heigth;
                    data.weight                         = model.Weight;
                    data.tin                            = model.Tin;
                    data.sss_number                     = model.SssNumber;
                    data.others_id                      = model.OthersId;
                    data.weight                         = model.Weight;
                    data.tin                            = model.Tin;
                    data.highest_education              = model.HighestEducation;
                    data.course                         = model.Course;
                    data.present_address                = model.PresentAddress;
                    data.address_status                 = model.AddressStatus;
                    data.provincial_address             = model.ProvincialAddress;
                    data.present_address_lenght_of_time = model.PresentAddressLengthOfTime;
                    data.contact_numbers                = model.ContactNumbers;
                    data.email_address                  = model.EmailAddress;
                    data.statuses_id                    = model.StatusesId;
                    data.employee_id                    = model.EmployeeId;
                    db.SaveChanges();
                    return(_resultHelper.Success());
                }
                catch (Exception ex)
                {
                    return(ex.Message);
                }
            }
        }
Esempio n. 8
0
        public string SaveSpouse(SpouseModel model)
        {
            ResultHelper _resultHelper = new ResultHelper();

            using (var db = new nasccoEntities())
            {
                using (DbContextTransaction dbTran = db.Database.BeginTransaction())
                {
                    try
                    {
                        var data = db.spouses.Create();
                        data.lastname           = model.SpouseLastName;
                        data.firstname          = model.SpouseFirstName;
                        data.middlename         = model.SpouseMiddleName;
                        data.date_of_birth      = model.SpouseDateOfBirth;
                        data.occupation         = model.SpouseOccupation;
                        data.employer           = model.SpouseEmployer;
                        data.employer_address   = model.SpouseEmployerAddress;
                        data.employer_contact   = model.SpouseEmployerContact;
                        data.monthly_income     = model.SpouseMonthlyIncome;
                        data.contact_numbers    = model.SpouseContactNumber;
                        data.employment_status  = model.SpouseEmploymentStatus;
                        data.member_id          = model.SpouseMemberId;
                        data.created_by_user_id = model.SpouseCreatedByUserId;
                        data.date_started       = DateTime.Now;
                        db.spouses.Add(data);
                        db.SaveChanges();

                        //Save if no issues
                        dbTran.Commit();
                        return(_resultHelper.Success());
                    }
                    catch (Exception ex)
                    {
                        dbTran.Rollback();
                        return(ex.Message);
                    }
                }
            }
        }
Esempio n. 9
0
        public string Update(UserModel model)
        {
            ResultHelper _resultHelper = new ResultHelper();

            using (var db = new nasccoEntities())
            {
                try
                {
                    var data = db.users.FirstOrDefault(x => x.id == model.UserId);
                    data.member_id   = model.UserMemberId;
                    data.roles_id    = model.RolesId;
                    data.statuses_id = model.UserStatusesId;
                    data.username    = model.Username;
                    db.SaveChanges();
                    return(_resultHelper.Success());
                }
                catch (Exception ex)
                {
                    return(ex.Message);
                }
            }
        }
Esempio n. 10
0
        public string UpdateReferences(ReferencesModel model)
        {
            ResultHelper _resultHelper = new ResultHelper();

            using (var db = new nasccoEntities())
            {
                try
                {
                    var data = db.references.FirstOrDefault(x => x.id == model.ReferencesId);
                    data.full_name      = model.ReferencesFullName;
                    data.relation       = model.ReferencesRelation;
                    data.address        = model.ReferencesAddress;
                    data.contact_number = model.ReferencesContactNumber;
                    db.SaveChanges();
                    return(_resultHelper.Success());
                }
                catch (Exception ex)
                {
                    return(ex.Message);
                }
            }
        }