public bool Add(NASEBUser entity) { entity.PasswordHash = Hasher.HashPassword(entity.PasswordHash); unitOfWork.Users.Add(entity); return(unitOfWork.SaveChnages() > 0); }
public IQueryable <NASEBRole> GetUserRolesByUserID(int id) { var user = new NASEBUser() { UserID = id }; return(unitOfWork.Roles.GetRolesByUser(user)); }
public static void GetDefaultData(IApplicationBuilder app) { var context = app.ApplicationServices.GetRequiredService <EFNASEBDBContext>(); context.Database.Migrate(); if (context.Roles.Count() == 0) { context.Roles.Add(new NASEBRole() { RoleName = "admin" }); context.Roles.Add(new NASEBRole() { RoleName = "employee" }); context.Roles.Add(new NASEBRole() { RoleName = "customer" }); } if (!context.Branches.Any()) { context.Branches.Add(new Branch() { BranchName = "NASEBMAIN", Phone = "4445252", Address = "NASEB MAH, SIVAS CAD, NO 52, ALTINORDU ORDU" }); } if (!context.Users.Any(a => a.EMail.Equals("*****@*****.**"))) { var user = new NASEBUser() { EMail = "*****@*****.**", Address = "NASEB MAH, SIVAS CAD, NO:58 ALTINORDU ORDU", BranchID = 1, PhoneNumber = "4445252", Name = "KARDEŞ", Surname = "DEDİKLERİMİZ", isActive = true, BirthDate = DateTime.Now.AddYears(34), RegisterDate = DateTime.Now, PasswordHash = Hasher.HashPassword("Naseb5252.") }; context.Add(new UserRole() { User = user, RoleID = 1 }); } context.SaveChanges(); }
public async Task <bool> ChangePasswordAsync(NASEBUser user, string password) { var _user = unitOfWork.Users.Get(a => a.UserID == user.UserID && a.EMail.Equals(user.EMail)); if (_user == null) { return(false); } user.PasswordHash = Hasher.HashPassword(password); unitOfWork.Users.Update(_user); return(await unitOfWork.SaveChangesAsync() > 0); }
public IActionResult Add(UserModel crmdl) { if (ModelState.IsValid) { var user = new NASEBUser(); user.Name = crmdl.Name; user.PasswordHash = Hasher.HashPassword(crmdl.Parola); user.Surname = crmdl.Surname; user.EMail = crmdl.Email; user.BirthDate = new DateTime(crmdl.Year, crmdl.Month, crmdl.Day); user.RegisterDate = DateTime.Now; user.PhoneNumber = crmdl.PhoneNumber; user.Address = crmdl.Adress; user.BranchID = crmdl.BranchID; service.Add(user); return(RedirectToAction("Index")); } else { return(View()); } }
public async Task <bool> UpdateAsync(NASEBUser entity) { unitOfWork.Users.Update(entity); return(await unitOfWork.SaveChangesAsync() > 0); }
public bool Update(NASEBUser entity) { unitOfWork.Users.Update(entity); return(unitOfWork.SaveChnages() > 0); }
public async Task <bool> AddAsync(NASEBUser entity) { entity.PasswordHash = Hasher.HashPassword(entity.PasswordHash); unitOfWork.Users.Add(entity); return(await unitOfWork.SaveChangesAsync() > 0); }
public IQueryable <NASEBRole> GetRolesByUser(NASEBUser user) { return(_context.Roles.Include(a => a.UserRoles).ThenInclude(q => q.User).Where(q => q.UserRoles.Any(a => a.UserID == user.UserID))); }