protected void UnloadData(User u) { u.Name = txtName.Text; u.Login = txtLogin.Text; if (txtPassword2.Text != "") { u = CntAriCli.EncryptPassword(u, txtPassword1.Text); } int id = Int32.Parse(ddlGroup.SelectedValue); u.UserGroup = (from ug in ctx.UserGroups where ug.UserGroupId == id select ug).FirstOrDefault <UserGroup>(); if (ddlProfessional.SelectedValue != "") { Professional p = CntAriCli.GetProfessional(int.Parse(ddlProfessional.SelectedValue), ctx); if (p != null) { p.User = u; } } u.Profile = int.Parse(ddlProfile.SelectedValue); u.BaseVisitType = (from bvt in ctx.BaseVisitTypes where bvt.Code == ddlBaseVisitType.SelectedValue select bvt).FirstOrDefault <BaseVisitType>(); }
private static void CreateThings() { // Create a user using (AriClinicContext ctx = new AriClinicContext("AriClinicContext")) { Console.WriteLine("Deleting all records...."); ctx.Delete(ctx.Logs); ctx.Delete(ctx.Users); ctx.Delete(ctx.UserGroups); ctx.Delete(ctx.HealthcareCompanies); ctx.SaveChanges(); Console.WriteLine("Creating default group.."); UserGroup ug = new UserGroup(); ug.Name = "Reservado"; ctx.Add(ug); Console.WriteLine("Creating administrator user.."); User user = new User(); user.Name = "Superuser"; user.Login = "******"; user.UserGroup = ug; user = CntAriCli.EncryptPassword(user, "admin"); ctx.Add(user); HealthcareCompany hc = new HealthcareCompany(); hc.Name = "Ariadna Salud S.L."; ctx.Add(hc); Clinic clinic = new Clinic() { Name = "Clinica 1" }; ctx.Add(clinic); // parameters Console.WriteLine("Creating parameters..."); AriCliModel.Parameter parameter = new Parameter() { PainPump = null, UseNomenclator = false }; ctx.Add(parameter); // processes Console.WriteLine("Creating process..."); Process process = new Process() { Name = "Administración", Code = "admin", }; Process admin = process; ctx.Add(admin); process = new Process() { Name = "Procesos", Code = "process", ParentProcess = admin }; ctx.Add(process); process = new Process() { Name = "Permisos", Code = "permision", ParentProcess = admin }; ctx.Add(process); // permissions Console.WriteLine("Creating permissions..."); Permission permission = new Permission() { Process = admin, UserGroup = ug, View = true, Create = true, Modify = true, Execute = true, }; ctx.Add(permission); permission = new Permission() { Process = process, // must be permission process UserGroup = ug, View = true, Create = true, Modify = true, Execute = true, }; ctx.Add(permission); // import data ctx.SaveChanges(); Console.WriteLine("All jobs done"); } }