public void CreateNew() { var newUser = new User(); var newPatient = new Patient() { Name = "Няма име", Number = "Няма номер" }; newUser.Patient = newPatient; this.User = newUser; this.FillView(); }
/// <summary> /// Logs in passed user /// </summary> /// <param name="user"></param> public static void LogInUser(User user) { if (user == null) { throw new ArgumentNullException("user must not be null!"); } Membership.CurrentUser = user; }
public static void DeleteUser(User user) { MedicalCardEntities context = new MedicalCardEntities(); if (user.EntityState == EntityState.Detached) { context.Users.Attach(user); } context.Users.DeleteObject(user); context.SaveChanges(); }
public static User GetAnonimousUser() { var user = new User() { UserName = "******", UserId = 0, DoctorId = null, RoleId = 0, PatientId = null }; return user; }
/// <summary> /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToUsers(User user) { base.AddObject("Users", user); }
/// <summary> /// Create a new User object. /// </summary> /// <param name="userId">Initial value of the UserId property.</param> public static User CreateUser(global::System.Int32 userId) { User user = new User(); user.UserId = userId; return user; }
/// <summary> /// Logs out curent user /// </summary> internal static void LogOutUser() { Membership.CurrentUser = UsersDataAccess.GetAnonimousUser(); }
private void SaveModel(User model) { try { if (User.UserId == 0) { User.RoleId = (int)UserRoles.Patient; UsersDataAccess.InsertUser(User); } else { UsersDataAccess.UpdateUser(User); } View.Message = "Успешен запис!"; } catch (Exception e) { var message = String.Format("Възникна грешка при съхраняване! Обадете се на администратор!/n {0} ", e.Message); View.Message = message; } }
public static void InsertUser(User user) { MedicalCardEntities context = new MedicalCardEntities(); if (user.EntityState != EntityState.Detached) { context.ObjectStateManager.ChangeObjectState(user, EntityState.Added); } else { context.Users.AddObject(user); } context.SaveChanges(); }
public static void UpdateUser(User user) { MedicalCardEntities context = new MedicalCardEntities(); context.Users.AddObject(user); context.ObjectStateManager.ChangeObjectState(user, EntityState.Modified); context.SaveChanges(); }