public static UserEntity ToBllUser(this DalUser dalUser) { return(new UserEntity() { UserId = dalUser.Id, Login = dalUser.Login, RoleId = dalUser.RoleId, Email = dalUser.Email, Password = dalUser.Password, UserPost = dalUser.UserPost.Select(p => new PostEntity() { Id = p.Id, Name = p.Name, AuthorLogin = p.AuthorLogin, DateOfPost = p.DateOfPost, SectionId = p.SectionId }), UserMessage = dalUser.UserMessage.Select(p => new MessageEntity() { Id = p.Id, Body = p.Body, AuthorLogin = p.AuthorLogin, DateOfMessage = p.DateOfMessage, AuthorId = p.AuthorId, PostID = p.PostID }), }); }
public void AddUserRoles(DalUser user, IEnumerable <DalRole> roles) { foreach (var role in roles) { AddUserRole(user, role); } }
public (ApiUser User, ApiLanguage Language) GetUserAndLanguage(string login, string password) { var languages = LanguageMapper.ConvertToApiEntitiesCollection(LanguageAdapter.GetAll()).ToList(); DalUser dalUser = null; var dalUsers = UserAdapter.GetAll($"login='******'"); var enumerable = dalUsers.ToList(); if (enumerable.Count() == 0) { throw new NotImplementedException(); //TODO: } if (enumerable.ElementAt(0).Password == $"{password}") { dalUser = enumerable.ElementAt(0); } else { throw new NotImplementedException(); //TODO: } var language = languages.Where(l => l.Id == dalUser.LanguageId).First(); var userDetails = UserDetailsMapper.ConvertToApiEntity(UserDetailsAdapter.GetById(dalUser.DetailsId)); UserMapper.Update(language, userDetails); var user = UserMapper.ConvertToApiEntity(dalUser); return(user, language); }
} // Invoke( Request.ICOMS ) #endregion // Methods #region Helper Functions /// <summary> /// The intent of this function is to populate the Connection Manager /// credentials into this class instance. This modularity allows for /// simple maintenance of this functionality when the call comes to /// change it. /// </summary> /// <param name="strLogon"> /// This is the username used to access Connection Manager. /// </param> /// <param name="strPassword"> /// This is the password used to access Connection Manager. /// </param> internal void PopulateCmCredentials(out string strLogon, out string strPassword) { // get the gateway id - in this case ConnectionManager int gatewayId = (int)TypeDescriptor.GetConverter( typeof(Gateway)).ConvertTo(Gateway.ConnectionManager, typeof(int)); try { DalUser dalUser = new DalUser(); IcomsCredential icomsCredential = dalUser.GetIcomsCredentials(gatewayId, _siteId, _userId); strLogon = icomsCredential.LoginName; strPassword = icomsCredential.Password; if (strLogon.Length < 1) { throw new RecordDoesNotExistException(); } } catch (DataSourceException dse) { throw new DataSourceUnavailableException(dse); } catch (RecordDoesNotExistException rdnee) { throw new RecordDoesNotExistException(string.Format("CM Icoms credentials do not exist for site id '{0}' and user id '{1}'", _siteId, _userId), rdnee); } catch (Exception e) { throw new UnexpectedSystemException(e); } } // PopulateCmCredentials()
public BllUser Find(int id) { DalUser user = userRepo.Find(id); FillAdditionalProperties(user); return(user.ToBal()); }
public void Update(DalUser entity) { var oldUser = context.Set <User>().Single(u => u.Id == entity.Id); oldUser.Name = entity.Name; oldUser.Password = entity.Password; }
internal static string FindEmailByAspId(string userId) { using (IDalUser dal = new DalUser()) { return(dal.GetEmailByAspId(userId)); } }
public void Create(DalUser user) { if (ReferenceEquals(user, null)) { throw new ArgumentNullException(nameof(user)); } var userRoles = user.Roles.ToList(); user.Roles.Clear(); var ormUser = user.ToUser(); foreach (var role in userRoles) { var dbRole = context.Context.Set <Roles>().FirstOrDefault(t => t.RoleName == role.RoleName); if (ReferenceEquals(dbRole, null)) { context.Context.Set <Roles>().Add(role.ToRole()); context.Commit(); dbRole = context.Context.Set <Roles>().FirstOrDefault(t => t.RoleName == role.RoleName); } if (ReferenceEquals(dbRole.Users, null)) { dbRole.Users = new List <Users>(); } dbRole.Users.Add(ormUser); } }
internal static IList <AspNetRoles> FindAllRole() { using (IDalUser dal = new DalUser()) { return(dal.GetAllRole()); } }
internal static string FindFirstnameByAspId(string userId) { using (IDalUser dal = new DalUser()) { return(dal.GetFirstnameByAspId(userId)); } }
internal static string FindRoleByAspId(string aspId) { using (IDalUser dal = new DalUser()) { return(dal.GetRoleByAspId(aspId)); } }
internal static SPP_UserInfo_Role_Result FindUserInfoById(string aspId) { using (IDalUser dal = new DalUser()) { return(dal.GetUserInfoById(aspId)); } }
internal static IList <SPP_UserInfo_Role_Result> FindAllUserInfo() { using (IDalUser dal = new DalUser()) { return(dal.GetALLUserInfo()); } }
public static Sorgu UserLoginProcess(string username, string password) { var user = DalUser.GetUser(username); var sorgu = new Sorgu(); if (user != null) { if (user.Password == password) { sorgu.isSuccess = true; sorgu.User = user; sorgu.Mesaj = "Giriş başarılı"; } else { sorgu.isSuccess = false; sorgu.Mesaj = "Şifre Hatalı"; } } else { sorgu.Mesaj = "Kullanıcı Adı Hatalı"; sorgu.isSuccess = false; } return(sorgu); }
internal static void AddUserInfo(string idUser, RegisterViewModel model) { using (IDalUser dal = new DalUser()) { dal.CreateUserInfo(idUser, model.Name, model.Firstname, model.Street, model.Zipcode, model.City, model.Phone); } }
public IEnumerable <DalTest> GetByAuthor(DalUser user) { if (context.Database.Connection.State != ConnectionState.Open) { context.Database.Connection.Open(); } IEnumerable <Tests> tests = context.Set <Tests>().Where(t => t.AuthorId == user.Id).AsEnumerable(); List <DalTest> result = new List <DalTest>(); foreach (Tests test in tests) { result.Add(new DalTest() { Id = test.id, AuthorId = test.AuthorId, Name = test.Name, Description = test.Description, AllowedTime = test.AllowedTime, Anonymous = test.Anonymous, CreationDate = test.CreationDate, GlobalAvailability = test.GlobalAvailability, Interview = test.Interview, QuestionCount = test.QuestionCount }); } return(result); }
internal static string FindIdRoleByName(string role) { using (IDalUser dal = new DalUser()) { return(dal.GetIdRoleByName(role)); } }
public void Delete(DalUser e) { var user = e.ToOrmUser(); user = _context.Set <UserLogin>().Single(u => u.Id == user.Id); _context.Set <UserLogin>().Remove(user); }
private void Button13_Click(object sender, EventArgs e) { User loggedInUser = Form1.LoggedInUser; try { if (loggedInUser.Password == textBox21.Text) { if (textBox22.Text == textBox23.Text) { loggedInUser.Password = textBox22.Text; var sorgu = DalUser.UpdateUser(loggedInUser); if (sorgu) { MessageBox.Show("Şifreniz güncellenmiştir.", "İşlem Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Yeni şifre ve şifre tekrarı aynı değil.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Mevcut şifreyi yanlış girdiniz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception) { MessageBox.Show("Eksik bilgi girdiniz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public void Delete(DalUser dalUser) { var user = dalUser.ToOrmUser(); user = context.Set <User>().Single(u => u.Id == user.Id); context.Set <User>().Remove(user); }
public void Create(DalUser user) { logger.Info($"{nameof(user)} => login:{user.Id} login:{user.Login} email:{user.Email}"); context.Set <User>() .Add(user.ToOrmUser()); }
/// <summary> /// Removing the user /// </summary> /// <param name="entity">user to remove</param> public void Delete(DalUser entity) { var user = context.Set <User>().FirstOrDefault(u => u.Id == entity.Id); var rolesUser = context.Set <RoleUser>().Where(r => r.UserId == user.Id); var markers = context.Set <Marker>().Where(m => m.UserId == user.Id); if (user != null) { context.Set <User>().Remove(user); } if (rolesUser != null) { foreach (var userRole in rolesUser) { context.Set <RoleUser>().Remove(userRole); } } if (markers != null) { foreach (var marker in markers) { context.Set <Marker>().Remove(marker); } } }
public long Registerwebsite(DtoUser dtouser) { try { long flag = 0; _daluser = new DalUser(); flag = _daluser.RegisterUser(dtouser); if (flag > 0) { var dalwebsite = new DalWebsite(); dalwebsite.RegisterWebsite(new DtoWebsite { WebSiteName = dtouser.FirstName, WebsiteUrl = dtouser.ImageUrl, UserId = flag }); } } catch (Exception ex) { ex.ToExceptionless().Submit(); } return(0); }
public IEnumerable <AnswerEntity> GetUserAnswers(string email, string search) { DalUser user = userRepository.GetByPredicate(ent => ent.Email == email).FirstOrDefault(); IEnumerable <DalTest> tests = testRepository.GetByPredicate(ent => ent.Name.ToLower().Contains(search.ToLower())); return(answerRepository.GetByPredicate(ent => ent.UserId == user.Id && tests.Any(ent1 => ent1.Id == ent.TestId)).Select(ent => ent.ToBllAnswer())); }
/// <summary> /// get point list of all deliveries location /// </summary> /// <returns> list of all deliveries location</returns> public static List <Point> GetDeliveriesLocations() { DataTable deliverersLocations = DalUser.GetDeliverersLocations(); return((from DataRow row in deliverersLocations.Rows select new Point(double.Parse(row["Lat"].ToString()), double.Parse(row["Lng"].ToString()))).ToList()); }
public void Update(DalUser entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } User user = context.Set <User>().Find(entity.Id); if (user == null) { return; } if (entity.Ban != null) { user.Ban = (bool)entity.Ban; } if (entity.Login != null) { user.Login = entity.Login; } if (entity.Password != null) { user.Password = entity.Password; } if (entity.UserName != null) { user.UserName = entity.UserName; } if (entity.RoleId != null) { user.RoleId = (int)entity.RoleId; } }
/// <summary> /// Updates user in data storage. /// </summary> /// <param name="user"> User to update.</param> /// <exception> System.ArgumentNullException if user is null.</exception> public void Update(DalUser user) { if (user == null) { throw new ArgumentNullException(nameof(user)); } var dbUser = context.Set <User>().Find(user.Id); var userRoles = dbUser.Roles.ToList(); context.Entry(dbUser).CurrentValues.SetValues(user); foreach (var userRole in userRoles) { var role = user.Roles?.SingleOrDefault(r => r.Id == userRole.Id); if (role != null) { context.Entry(userRole).CurrentValues.SetValues(role); } else { dbUser.Roles.Remove(userRole); } } var roles = context.Set <Role>(); foreach (var role in user.Roles) { if (!userRoles.Any(r => r.Id == role.Id)) { dbUser.Roles.Add(roles.SingleOrDefault(r => r.Id == role.Id) ?? role.ToRole()); } } }
public void Update(DalUser entity) { var updatedUser = entity.ToUser(); var existedUser = _dbContext.Entry <User>(_dbContext.Set <User>().Find(updatedUser.UserId)); if (existedUser == null) { return; } existedUser.State = EntityState.Modified; existedUser.Collection(u => u.Roles).Load(); existedUser.Entity.Roles.Clear(); foreach (Role role in updatedUser.Roles) { var loaded = _dbContext.Set <Role>().Find(role.RoleId); existedUser.Entity.Roles.Add(loaded); } existedUser.Entity.BlockReason = entity.BlockReason; existedUser.Entity.BlockTime = entity.BlockTime; existedUser.Entity.IsBlocked = entity.IsBlocked; existedUser.Entity.Photo = entity.Photo; existedUser.Entity.Login = entity.Login; existedUser.Entity.Email = entity.Email; existedUser.Entity.Password = entity.Password; }
/// <summary> /// constructor by data row /// </summary> /// <param name="pass"></param> public BlUser(string pass) { DataTable t = null; try { t = DalUser.IsExist(pass); } catch { return; } if (t == null || t.Rows.Count <= 0) { return; } DataRow row = t.Rows[0]; UserId = row["ID"].ToString(); Type = int.Parse(row["UserType"].ToString()); Email = row["Email"].ToString(); Phone = row["PhoneNumber"].ToString(); FirstName = row["FirstName"].ToString(); LastName = row["LastName"].ToString(); Password = row["Password"].ToString(); Location = new Point(double.Parse(row["Lng"].ToString()), double.Parse(row["Lng"].ToString())); }
public void Create(DalUser entity) { var user = entity.ToUser(); user.Roles = user.Roles.Select(t => _dbContext.Set <Role>().Find(t.RoleId)).ToList(); AttachRoles(user.Roles); _dbContext.Set <User>().Add(user); }