public void DeleteUser(User user) { try { userRepository.DeleteUser(user); } catch (Exception ex) { throw ex; } }
public void DeleteUser(User user) { try { context.Users.Attach(user); context.Users.Remove(user); //context.Entry(user).State = EntityState.Deleted; context.SaveChanges(); } catch (Exception ex) { throw ex; } }
public Int64 RegisterUser(object [] RegisterUser) { int companyid = Convert.ToInt32(RegisterUser[9]); int teamsetid = createDefaultTeamSet(companyid); Int64 teamid = createDefaultTeam(companyid, teamsetid); string password = Convert.ToString(RegisterUser[11]); string fullhash = Authentication.CreateHash(password); string[] split = fullhash.Split(':'); string salt = split[1]; string hash = split[2]; try { var user = new User { FirstName = RegisterUser[0].ToString(), LastName = RegisterUser[1].ToString(), Designation = RegisterUser[2].ToString(), Street = RegisterUser[3].ToString(), City = RegisterUser[4].ToString(), PostalCode = RegisterUser[5].ToString(), CountryID = Convert.ToInt32(RegisterUser[6]), MobilePhone = RegisterUser[7].ToString(), PrimaryEmail = RegisterUser[8].ToString(), CompanyID = Convert.ToInt32(RegisterUser[9]), RoleID = Convert.ToInt32(RegisterUser[10]), CreatedTime = DateTime.Now, ModifiedTime = DateTime.Now, ActivationID = Guid.NewGuid(), Password = hash, PasswordSalt = salt, IsActive = true, IsEmployee = true, IsApproved = false, IsFirstLogin = true, TeamID = teamid, TeamSetID = teamsetid, IsAdmin = true }; context.Users.Add(user); context.SaveChanges(); Int64 id = user.UserID; User user1 = context.Users.Single(q => q.UserID == id); user1.CreatedBy = id; user1.ModifiedBy = id; context.SaveChanges(); return id; } catch (Exception ex) { throw ex; } }
public void InsertUser(User user) { try { context.Entry(user).State = EntityState.Added; context.SaveChanges(); } catch (Exception ex) { throw ex; } }
public Int64 InsertOrUpdate(User user) { string pemail = user.PrimaryEmail; bool emailaddress = true; emailaddress = IsEmailExists(pemail); if (user.UserID == 0 && emailaddress == false) { string password = user.Password; string fullhash = Authentication.CreateHash(password); string[] split = fullhash.Split(':'); string salt = split[1]; string hash = split[2]; user.Password = hash; user.PasswordSalt = salt; user.IsApproved = true; user.IsFirstLogin = true; context.Entry(user).State = EntityState.Added; context.SaveChanges(); } else if (user.UserID > 0) { user.IsApproved = true; user.IsFirstLogin = false; context.Entry(user).State = EntityState.Modified; context.SaveChanges(); } Int64 id = user.UserID; return id; }
public void UpdateUser(User user) { try { //context.Users.Attach(user); context.Entry(user).State = EntityState.Modified; context.SaveChanges(); } catch (Exception ex) { throw ex; } }
private void ValidateUser(User user) { string pemail = user.PrimaryEmail; var emailaddress = userRepository.IsEmailExists(pemail); if (emailaddress == true && user.UserID==0) { throw new UserException(String.Format("Primary Email Address already exists. Please try another one.", pemail)); } }
public void InsertUser(User user) { try { userRepository.InsertUser(user); } catch (Exception ex) { throw ex; } }
public long InsertOrUpdate(User user) { try { ValidateUser(user); return userRepository.InsertOrUpdate(user); } catch (Exception ex) { throw ex; } }