public static bool Edit( user objUser, string stUsername, string stEmail, string stCellphone, string stPassword, string stFirstname, string stLastname, byte byRoleAccess, string stExtradata, string stNamePicture, byte[] byaPicture, DateTime objDateBirthday, string stState, string stCity, session objSession) { try { using (straad_generaldesktopapplication_pcpcpcpc_001Entities objContext = new straad_generaldesktopapplication_pcpcpcpc_001Entities()) { var vUserPrincipal = objContext.users.Where(u => u.user_uuid__uniqueidentifier == objUser.user_uuid__uniqueidentifier).FirstOrDefault(); var vLastBranch = objContext.proc_user_findAllBranches(objUser.user_uuid__uniqueidentifier).LastOrDefault(); // Add User Guid objGuidUserAux = Guid.NewGuid(); do { objGuidUserAux = Guid.NewGuid(); } while (FindByUUID(objGuidUserAux) != null); user objUserAux = new user() { user_uuid__uniqueidentifier = objGuidUserAux, user_username__nvarchar = vUserPrincipal.user_username__nvarchar, user_email__nvarchar = vUserPrincipal.user_email__nvarchar, user_cellphone__nvarchar = vUserPrincipal.user_cellphone__nvarchar, user_password__nvarchar = vUserPrincipal.user_password__nvarchar, user_firstname__nvarchar = vUserPrincipal.user_firstname__nvarchar, user_lastname__nvarchar = vUserPrincipal.user_lastname__nvarchar, user_roleaccess__tinyint = vUserPrincipal.user_roleaccess__tinyint, user_extradata__nvarchar = vUserPrincipal.user_extradata__nvarchar, reso_uuid_picture__uniqueidentifier = vUserPrincipal.reso_uuid_picture__uniqueidentifier, date_uuid_birthdate__uniqueidentifier = vUserPrincipal.date_uuid_birthdate__uniqueidentifier, city_uuid__uniqueidentifier = vUserPrincipal.city_uuid__uniqueidentifier, sess_uuid_used__uniqueidentifier = null, sess_uuid_created__uniqueidentifier = vUserPrincipal.sess_uuid_created__uniqueidentifier, user_uuid_root__uniqueidentifier = vLastBranch.user_uuid__uniqueidentifier, sess_uuid_deleted__uniqueidentifier = null }; objContext.users.Add(objUserAux); // Add Date Guid?objGuidDate = null; if (objDateBirthday.Year != DateTime.Now.Year) { objGuidDate = BDate.FindOrAddDate(objDateBirthday).date_uuid__uniqueidentifier; } // Add City Guid?objGuidCity = null; if (!string.IsNullOrEmpty(stCity)) { objGuidCity = BCity.FindByName(stCity, BState.FindByName(stState, BCountry.FindByCode("MX"))).city_uuid__uniqueidentifier; } // Add Resource Guid?objGuidResource = null; if (byaPicture != null && !string.IsNullOrEmpty(stNamePicture)) { objGuidResource = BResource.Add(stNamePicture, 1, null, byaPicture, null).reso_uuid__uniqueidentifier; } vUserPrincipal.user_username__nvarchar = stUsername; vUserPrincipal.user_email__nvarchar = stEmail; vUserPrincipal.user_cellphone__nvarchar = stCellphone; vUserPrincipal.user_password__nvarchar = stPassword != Preferences.GlobalTextToComparePasswords ? Tools.Encrypt(stPassword) : objUserAux.user_password__nvarchar; //txtPassword.Text != Preferences.GlobalTextToComparePasswords ? Tools.Encrypt(txtPassword.Text) : objUserSelectedPrincipalItem.user_password__nvarchar, //vUserPrincipal.user_password__nvarchar = Tools.GetDefaulHash(stPassword); vUserPrincipal.user_firstname__nvarchar = Tools.Encrypt(stFirstname); vUserPrincipal.user_lastname__nvarchar = Tools.Encrypt(stLastname); vUserPrincipal.user_roleaccess__tinyint = byRoleAccess; vUserPrincipal.user_extradata__nvarchar = stExtradata; vUserPrincipal.reso_uuid_picture__uniqueidentifier = objGuidResource; vUserPrincipal.date_uuid_birthdate__uniqueidentifier = objGuidDate; vUserPrincipal.city_uuid__uniqueidentifier = objGuidCity; vUserPrincipal.sess_uuid_used__uniqueidentifier = null; vUserPrincipal.sess_uuid_created__uniqueidentifier = objSession.sess_uuid__uniqueidentifier; vUserPrincipal.user_uuid_root__uniqueidentifier = null; vUserPrincipal.sess_uuid_deleted__uniqueidentifier = null; objContext.SaveChanges(); return(true); } } catch { } return(false); }
public static bool Edit( principalcompany objPrincipalCompany, string stRfc, string stName, string stAddress, string stPhone, string stEmail, string stFacebookUrl, bool boDevelopmentMode, int inHoursBetweenBackups, int inDaysDeleteBackups, string stNamePicture, byte[] byaPicture, string stState, string stCity, session objSession) { try { using (ModelContext objContext = new ModelContext()) { var vPreferencePrincipal = objContext.principalcompanies.Where(p => p.prco_uuid__uniqueidentifier == objPrincipalCompany.prco_uuid__uniqueidentifier).FirstOrDefault(); var vLastBranch = objContext.proc_principalcompany_findAllBranches(objPrincipalCompany.prco_uuid__uniqueidentifier).LastOrDefault(); // Add Preference Guid objGuidPreferenceAux = Guid.NewGuid(); do { objGuidPreferenceAux = Guid.NewGuid(); } while (FindByUUID(objGuidPreferenceAux) != null); principalcompany objPrincipalCompanyAux = new principalcompany() { prco_uuid__uniqueidentifier = objGuidPreferenceAux, prco_rfc__nvarchar = vPreferencePrincipal.prco_rfc__nvarchar, prco_name__nvarchar = vPreferencePrincipal.prco_name__nvarchar, prco_address__nvarchar = vPreferencePrincipal.prco_address__nvarchar, prco_phone__nvarchar = vPreferencePrincipal.prco_phone__nvarchar, prco_email__nvarchar = vPreferencePrincipal.prco_email__nvarchar, prco_facebook__nvarchar = vPreferencePrincipal.prco_facebook__nvarchar, prco_developmentmode__bit = vPreferencePrincipal.prco_developmentmode__bit, prco_hoursbetweenbackups__int = vPreferencePrincipal.prco_hoursbetweenbackups__int, prco_daysdeletbackups__int = vPreferencePrincipal.prco_daysdeletbackups__int, reso_uuid_logo__uniqueidentifier = vPreferencePrincipal.reso_uuid_logo__uniqueidentifier, city_uuid__uniqueidentifier = vPreferencePrincipal.city_uuid__uniqueidentifier, sess_uuid_used__uniqueidentifier = null, sess_uuid_created__uniqueidentifier = vPreferencePrincipal.sess_uuid_created__uniqueidentifier, prco_uuid_root__uniqueidentifier = vLastBranch.prco_uuid__uniqueidentifier }; objContext.principalcompanies.Add(objPrincipalCompanyAux); // Add City Guid?objGuidCity = null; if (!string.IsNullOrEmpty(stCity)) { objGuidCity = BCity.FindByName(stCity, BState.FindByName(stState, BCountry.FindByCode("MX"))).city_uuid__uniqueidentifier; } // Add Resource Guid?objGuidResource = null; if (byaPicture != null && !string.IsNullOrEmpty(stNamePicture)) { objGuidResource = BResource.Add(stNamePicture, 1, null, byaPicture, null).reso_uuid__uniqueidentifier; } vPreferencePrincipal.prco_rfc__nvarchar = stRfc; vPreferencePrincipal.prco_name__nvarchar = stName; vPreferencePrincipal.prco_address__nvarchar = stAddress; vPreferencePrincipal.prco_phone__nvarchar = stPhone; vPreferencePrincipal.prco_email__nvarchar = stEmail; vPreferencePrincipal.prco_facebook__nvarchar = stFacebookUrl; vPreferencePrincipal.prco_developmentmode__bit = boDevelopmentMode; vPreferencePrincipal.prco_hoursbetweenbackups__int = inHoursBetweenBackups; vPreferencePrincipal.prco_daysdeletbackups__int = inDaysDeleteBackups;//vPreferencePrincipal.prco_timebetweenbackups__int = inTimeBetweenBackups > 0 ? inTimeBetweenBackups: null; vPreferencePrincipal.reso_uuid_logo__uniqueidentifier = objGuidResource; vPreferencePrincipal.city_uuid__uniqueidentifier = objGuidCity; vPreferencePrincipal.sess_uuid_used__uniqueidentifier = null; vPreferencePrincipal.sess_uuid_created__uniqueidentifier = objSession.sess_uuid__uniqueidentifier; vPreferencePrincipal.prco_uuid_root__uniqueidentifier = null; objContext.SaveChanges(); return(true); } } catch { } return(false); }
public static user Add( string stUsername, string stEmail, string stCellphone, string stPassword, string stFirstname, string stLastname, byte byRoleAccess, string stExtradata, string stNamePicture, byte[] byaPicture, DateTime objDateBirthday, string stState, string stCity, session objSessionCreator) { try { using (straad_generaldesktopapplication_pcpcpcpc_001Entities objContext = new straad_generaldesktopapplication_pcpcpcpc_001Entities()) { // Add Date Guid?objGuidDate = null; if (objDateBirthday.Year != DateTime.Now.Year) { objGuidDate = BDate.FindOrAddDate(objDateBirthday).date_uuid__uniqueidentifier; } // Add City Guid?objGuidCity = null; if (!string.IsNullOrEmpty(stCity)) { objGuidCity = BCity.FindByName(stCity, BState.FindByName(stState, BCountry.FindByCode("MX"))).city_uuid__uniqueidentifier; } // Add Resource Guid?objGuidResource = null; if (byaPicture != null && !string.IsNullOrEmpty(stNamePicture)) { objGuidResource = BResource.Add(stNamePicture, 1, null, byaPicture, null).reso_uuid__uniqueidentifier; } // Add User Guid objGuidUser = Guid.NewGuid(); do { objGuidUser = Guid.NewGuid(); } while (FindByUUID(objGuidUser) != null); objContext.users.Add(new user() { user_uuid__uniqueidentifier = objGuidUser, user_username__nvarchar = stUsername, user_email__nvarchar = stEmail, user_cellphone__nvarchar = stCellphone, user_password__nvarchar = Tools.GetDefaulHash(stPassword), user_firstname__nvarchar = Tools.Encrypt(stFirstname), user_lastname__nvarchar = Tools.Encrypt(stLastname), user_roleaccess__tinyint = byRoleAccess, user_extradata__nvarchar = stExtradata, reso_uuid_picture__uniqueidentifier = objGuidResource, date_uuid_birthdate__uniqueidentifier = objGuidDate, city_uuid__uniqueidentifier = objGuidCity, sess_uuid_used__uniqueidentifier = null, sess_uuid_created__uniqueidentifier = objSessionCreator.sess_uuid__uniqueidentifier, user_uuid_root__uniqueidentifier = null, sess_uuid_deleted__uniqueidentifier = null }); objContext.SaveChanges(); return(objContext.users.Where(u => u.user_uuid__uniqueidentifier == objGuidUser).FirstOrDefault()); } } catch { } return(null); }