public async Task <IHttpActionResult> delete(string userId) { //if (!ModelState.IsValid) //{ // return BadRequest(ModelState); //} Boolean result = true; DAL.User nowUser = _db.Users.Where(p => p.userID == userId).First(); DAL.AspNetUser nowAccount = _db.AspNetUsers.Where(p => p.Id == userId).First(); if (nowUser != null && nowAccount != null) { try { System.Web.HttpContext.Current.Application.Lock(); _db.Users.Remove(nowUser); _db.SaveChanges(); _db.AspNetUsers.Remove(nowAccount); _db.SaveChanges(); System.Web.HttpContext.Current.Application.UnLock(); } catch (Exception e) { result = false; } } return(Json(new { result = result })); }
public async Task <IHttpActionResult> update(UserModels model) { if (!ModelState.IsValid) { return(Json(new { error = true, message = Models.ErrorMessage.getErrorMessage(ModelState) })); } Boolean result = true; try { System.Web.HttpContext.Current.Application.Lock(); DAL.User nowUser = _db.Users.Where(p => p.userID == model.userID).First(); DAL.AspNetUser nowAccount = _db.AspNetUsers.Where(p => p.Id == nowUser.userID).First(); //DAL.User gen = new DAL.User(); nowUser.titleNameID = (int)model.titleNameID; nowUser.personalID = model.personalID; nowUser.firstname = model.firstname; nowUser.lastname = model.lastname; nowUser.userTypeID = (int)model.userTypeID; nowUser.status = (int)model.status; nowUser.commanderID = model.commanderID; nowUser.personalID = model.personalID; nowAccount.Email = model.email; _db.SaveChanges(); System.Web.HttpContext.Current.Application.UnLock(); } catch (Exception e) { result = false; } return(Json(new { result = result })); }
public ActionResult NewUser(Models.BaseUserModel model) { ViewBag.Message = "I've not seen you before; please select your default Active Directory Group below, and click Save."; if (model == null) { new Models.BaseUserModel(Roles.GetRolesForUser()); } else { DAL.User usr = UserRepository.GetUser(User.Identity.Name); if (usr == null) { usr = new DAL.User(); usr.Account = User.Identity.Name; } usr.DefaultGroup = model.DefaultRole; UserRepository.UpdateUser(usr); return RedirectToAction("Index"); } return View(); }
private void enter_Click(object sender, EventArgs e) { if (txtAmount.Text == "") { txtAmount.Focus(); return; } int Amount = Convert.ToInt32(txtAmount.Text); txtAmount.Text = ""; DAL.User u = new DAL.User(); Amount = (Int32)Money + Amount; u.Id = User_Id; u.Balance = Amount; if (u.Update()) { MessageBox.Show("Account info Updated!"); } else { MessageBox.Show(u.Error); } }
/// <summary> /// Inserts a new User /// </summary> /// <returns>the inserted user's id</returns> public override void Insert(User user) { if (user == null) { throw new ArgumentNullException("user"); } if (Exists(user.Username)) { throw new Exception(String.Format("User {0} already exists.", user.Username)); } // insert the user DAL.User newUser = new DAL.User { Enabled = user.Enabled, Password = user.Password, Role = ((short)user.Role), Username = user.Username }; newUser.Save(); // add user profile _profileController.Insert(newUser.Id, user.FirstName, user.LastName, user.Address, user.City, user.State, user.ZipCode, user.PhoneNumber, user.Email); // update the passed in user object user.ID = newUser.Id; // assign the user to a manager if (user.ManagerID > 0) { AssignManager(user.ID, user.ManagerID); } }
public long addUser(DAL.User user) { long res = -1; // set default values for the user user.CreateDate = DateTime.Now; user.LastUpdate = DateTime.Now; user.NextTask = DateTime.Now; user.TaskInterval = 10; //default value is 10 minutes try { using (var db = _context) { // Create Console.WriteLine("Inserting a new user"); db.Users.Add(user); db.SaveChanges(); res = user.UserId; } } catch (Exception ex) { Console.WriteLine(ex.GetType()); throw new Exception(ex.ToString()); } return(res); }
public void Handle(Command message) { var user = new DAL.User { DisplayName = message.DisplayName, Login = message.Login }; db.Users.Add(user); db.SaveChanges(); if (message.PrimaryEmailAddress != null) { user.PrimaryEmailAddress = new UserEmailAddress { User = user, Value = message.PrimaryEmailAddress, IsVerified = true }; } if (message.PrimaryPhoneNumber != null) { user.PrimaryPhoneNumber = new UserPhoneNumber { User = user, Label = "Primary", Value = message.PrimaryPhoneNumber, IsVerified = true }; } }
private void btnDeleteAccount_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("R u Sure?", "Delete confermation", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (dr == DialogResult.No || dr == DialogResult.Cancel) { return; } DAL.User user = new DAL.User(); DAL.Info info = new DAL.Info(); int Id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["id"].Value); user.Id = Id; info.Id = Id; if (info.Delete() && user.Delete()) { Show_Gridview(); } else { MessageBox.Show(user.Error + info.Error); } }
public ActionResult ReportInterface() { var filters = new FiltersModel(); List <Company> allCompanies = dataContext.Company.ToList(); Company firstCompany = new Company(); firstCompany.Id = 0; firstCompany.CompanyName = "Select a company"; allCompanies.Insert(0, firstCompany); List <Contract> allContracts = dataContext.Contract.ToList(); Contract firstContract = new Contract(); firstContract.Id = 0; firstContract.ContractName = "Select a contract type"; allContracts.Insert(0, firstContract); List <User> allUsers = dataContext.User.Distinct().ToList(); User firstUser = new DAL.User(); firstUser.Id = 0; firstUser.Name = "Select a user"; allUsers.Insert(0, firstUser); filters.CompanyList = allCompanies; filters.UserList = allUsers; filters.ContractList = allContracts; return(View(filters)); }
public bool CreateUser(User user) { int deptId = user.DeptId.Value; int roleId = user.RoleId.Value; facAppDataRepo.AddUser(_mapper.Map <DAL.User>(user)); facAppDataRepo.SaveChangesToDB(); DAL.User usr = facAppDataRepo.GetUser(user.EmailId, user.Pwd); if (user.RoleId == 2) { facAppDataRepo.AddFaculty(new DAL.Faculty() { DeptId = deptId, IsScheduleEditEnabled = false, Uid = usr.Uid }); } else if (user.RoleId == 3) { facAppDataRepo.AddStudent(new DAL.Student() { DeptId = deptId, Uid = usr.Uid }); } bool status = facAppDataRepo.SaveChangesToDB(); return(status); }
public Bid Get(int id) { var pt = db.Bids.Where(x => x.Id == id).FirstOrDefault(); if (pt != null) { Bid pd = new Bid(); pd.Id = pt.Id; pd.Amount = pt.Amount.HasValue ? pt.Amount.Value : 0; DAL.User user = db.Users.Where(x => x.Id == pt.BidderId).FirstOrDefault(); if (user != null) { pd.User = new User(); pd.User.Email = user.Email; pd.User.Password = user.Password; pd.User.Address = user.Address; DAL.Bank b = db.Banks.Where(x => x.Id == user.BankDetailId).FirstOrDefault(); if (b != null) { pd.User.BankDetails = new Bank(); pd.User.BankDetails.Id = b.Id; pd.User.BankDetails.AccountNumber = b.AccountNbr; pd.User.BankDetails.Balance = b.Balance.HasValue ? b.Balance.Value : 0; } } pd.AuctionId = pt.AuctionId.HasValue ? pt.AuctionId.Value : 0; return(pd); } return(null); }
public ActionResult <List <DTO.Reservation> > GetResByUserId(int id) { List <DAL.Reservation> dalreservations = new List <DAL.Reservation>(); dalreservations = DAL.UserManager.ListUserReservations(id); List <DTO.Reservation> dtoreservations = new List <DTO.Reservation>(); foreach (var dalreservation in dalreservations) { DTO.Reservation dtoreservation = new DTO.Reservation(); dtoreservation.ReservationId = dalreservation.ReservationId; dtoreservation.MovieEvent = new DTO.MovieEvent(); dtoreservation.MovieEvent.Movie = new DTO.Movie(); dtoreservation.MovieEvent.Room = new DTO.Room(); dtoreservation.MovieEvent.MovieEventId = dalreservation.MovieEventId; dtoreservation.MovieEvent.Time = dalreservation.MovieEvent.TimeOfEvent; dtoreservation.MovieEvent.Movie.MovieId = dalreservation.MovieEvent.Movie.MovieId; dtoreservation.MovieEvent.Movie.Title = dalreservation.MovieEvent.Movie.Title; dtoreservation.MovieEvent.Movie.Length = dalreservation.MovieEvent.Movie.Length; dtoreservation.MovieEvent.Movie.Img = dalreservation.MovieEvent.Movie.Img; dtoreservation.MovieEvent.Room.RoomId = dalreservation.MovieEvent.Room.RoomId; dtoreservation.MovieEvent.Room.RoomNumber = dalreservation.MovieEvent.Room.RoomNumber; DAL.User daluser = DAL.UserManager.GetUserById(dalreservation.UserId); dtoreservation.User = new DTO.User(); dtoreservation.User.Name = daluser.Name; dtoreservation.User.UserId = daluser.UserId; DAL.Seat dalseatt = DAL.RoomManager.GetSeatById(dalreservation.SeatId); dtoreservation.Seat = new DTO.MovieEventSeat(); dtoreservation.Seat.SeatId = dalseatt.SeatId; dtoreservation.Seat.SeatNumber = dalseatt.SeatNumber; dtoreservation.Seat.RowNumber = dalseatt.RowNumber; dtoreservations.Add(dtoreservation); } return(dtoreservations); }
public void AddNewUser_ValidUser_ReturnsAllUsers() { bool isValidTask = false; while (!isValidTask) { var TaskId = new Random().Next(); var TaskInDb = _UsersController.GetUser(TaskId); if (TaskInDb.GetType() == typeof(NotFoundResult)) { isValidTask = true; var Task = new DAL.User() { User_ID = TaskId, Employee_ID = new Random().Next(), FirstName = "Test_First Name", LastName = "Test_LastNmae" }; IHttpActionResult actionResult = _UsersController.PostUser(Task); var contentResult = ((System.Web.Http.Results.CreatedAtRouteNegotiatedContentResult <ProjectManagement.DAL.User>)actionResult); Assert.IsNotNull(contentResult); Assert.IsNotNull(contentResult.Content); } } }
private void enter_Click(object sender, EventArgs e) { int er = 0; ep.Clear(); if (txtAmount.Text == "") { txtAmount.Focus(); return; } if (cmbAccountNumber.SelectedValue == null || cmbAccountNumber.SelectedValue.ToString() == "") { er++; ep.SetError(cmbAccountNumber, "Required"); } if (er > 0) { return; } int Amount = Convert.ToInt32(txtAmount.Text); txtAmount.Text = ""; if (Amount > (Int32)Money) { txtAmount.Text = ""; txtInfo.Text = "Insufficient Balance!"; } if (Amount < 100) { txtAmount.Text = ""; txtInfo.Text = "Transaction isn't possible!"; } if (Amount <= (Int32)Money && Amount >= 100) { DAL.User user = new DAL.User(); DAL.User u = new DAL.User(); user.Id = Convert.ToInt32(cmbAccountNumber.SelectedValue); user.Select_Balance(); user.Balance += Amount; Amount = (Int32)Money - Amount; u.Id = User_Id; u.Balance = Amount; if (user.Update() && u.Update()) { MessageBox.Show("Money Transfer Successfully!"); } else { MessageBox.Show(u.Error + user.Error); } } }
public void Add(Object us) { Backend.User user = (Backend.User)us; DB.Add(user); DAL.User toAdd = Change.UserBackendToDal(user); sqlDB.Users.InsertOnSubmit(toAdd); sqlDB.SubmitChanges(); }
public static DAL.User UserBackendToDal(Backend.User u) { DAL.User ans = new DAL.User(); ans.ID = u.ID; ans.userName = u.userName; ans.password = u.password; return(ans); }
internal User(SessionToken sessionToken, ITime time, IDatabase database, Permission permission, Role role) { _storage = new DAL.User(database); _sessionToken = sessionToken; _time = time; _permission = permission; _role = role; }
/// <summary> /// Updates the enabled. /// </summary> /// <param name="id">The id.</param> /// <param name="enabled">if set to <c>true</c> [enabled].</param> /// <returns></returns> public void Enable(int id, bool enabled) { DAL.User user = new DAL.User(id) { Enabled = enabled }; user.Save(); }
public void Handle(CreateCommand message) { var user = new DAL.User { DisplayName = message.Name, Login = message.Name }; db.Users.Add(user); }
protected override void Handle(CreateCommand request) { var user = new DAL.User { DisplayName = request.Name, Login = request.Name }; db.Users.Add(user); }
public static UserEntity FromDalToEntity(DAL.User user) { return(new UserEntity() { Name = user.Name, FullName = user.FullName, AvatarUrl = user.AvatarURL }); }
public IActionResult Create(DTO.User item) { var dalitem = new DAL.User(); dalitem.Name = item.Name; dalitem.TelephoneNumber = item.TelephoneNumber; dalitem.Email = item.Email; DAL.UserManager.AddUser(dalitem); return(Created("http://localhost:6544/api/user", item)); }
public ActionResult <DTO.User> GetById(int id) { DAL.User daluser = DAL.UserManager.GetUserById(id); DTO.User dtouser = new DTO.User(); dtouser.Name = daluser.Name; dtouser.UserId = daluser.UserId; dtouser.TelephoneNumber = daluser.TelephoneNumber; dtouser.Email = daluser.Email; return(dtouser); }
public void Post([FromBody] object newPassword) { JObject juser = newPassword as JObject; PasswordObject passwordObject = juser.ToObject <PasswordObject>(); DAL.User user = userController.GetById(passwordObject.userId); UserProxy.UpdateUser(user.Id); user.password = passwordObject.newPassword; userController.EditUser(user.Id, user); }
public BLL.User MapUser(DAL.User user) { return(new BLL.User { FirstName = user.FirstName, LastName = user.LastName, Age = user.Age // etc... }); }
public static User FromEntity(DAL.User data) { return(new User() { Balance = data.Balance, EMail = data.Email, Id = data.Id, Name = data.Name, Password = data.Password }); }
public static bool IsPasswordForUser(this DAL.User dbUser, string password) { byte[] saltBytes = Convert.FromBase64String(dbUser.PasswordSalt); using (var crypto = new Rfc2898DeriveBytes(password, saltBytes, iterationNumber)) { string encryptedPassword = Convert.ToBase64String(crypto.GetBytes(32)); return(dbUser.Password == encryptedPassword); } }
public static DTO.UserDto ConvertDALtoDTO(DAL.User u) { return(new DTO.UserDto() { IsAdmin = u.IsAdmin, UserID = u.UserID, UserPassword = u.UserPassword, CompanyId = u.CompanyId, Company = ConvertCompany.ConvertDALtoDTO(u.Company), Username = u.Username }); }
public void Show_Gridview() { DAL.User user = new DAL.User(); var ds = user.Select(); if (ds == null) { return; } dataGridView1.DataSource = user.Select().Tables[0]; }
public void Add(DAL.User user) { try { _context.Add(user); _context.SaveChanges(); } catch (Exception) { throw; } }
public async Task <Guid> Create(API.User user, string password, string[] groups, CancellationToken cancellation) { if (await Connection.ExistsAsync <DAL.Login>(l => l.EmailOrUserName == user.EmailOrUserName && l.DeletedUtc == null, cancellation)) { throw new InvalidOperationException(Resources.USER_ALREADY_EXISTS); } Guid[] groupIds = (await Connection.SelectAsync <DAL.Group>(grp => Sql.In(grp.Name, groups.Distinct()), cancellation)) .Select(grp => grp.Id) .ToArray(); if (groupIds.Length != groups.Length) { throw new InvalidOperationException(Resources.INVALID_GROUP); } using (IBulkedDbConnection bulk = Connection.CreateBulkedDbConnection()) { var loginEntry = new DAL.Login { EmailOrUserName = user.EmailOrUserName, PasswordHash = HashPassword(password, GenerateSalt()) }; bulk.Insert(loginEntry); Debug.Assert(loginEntry.Id != Guid.Empty); var userEntry = new DAL.User { LoginId = loginEntry.Id, FullName = user.FullName }; bulk.Insert(userEntry); Debug.Assert(userEntry.Id != Guid.Empty); // // Don't use InsertAll() since it gives the same Id for each entry // foreach (Guid groupId in groupIds) { var ug = new DAL.UserGroup { GroupId = groupId, UserId = userEntry.Id }; bulk.Insert(ug); Debug.Assert(ug.Id != Guid.Empty); } await bulk.FlushAsync(cancellation); return(userEntry.Id); } }
public void Save(User user) { DAL.User u = new DAL.User(); u.Email = user.Email; u.Password = user.Password; u.RoleId = (int)user.Role; u.Address = user.Address; u.Bank = new DAL.Bank(); u.Bank.AccountNbr = user.BankDetails.AccountNumber; u.Bank.Balance = user.BankDetails.Balance; db.Banks.InsertOnSubmit(u.Bank); db.SubmitChanges(); u.BankDetailId = u.Bank.Id; db.Users.InsertOnSubmit(u); db.SubmitChanges(); }
private void btnEditUser_Click(object sender, System.Windows.RoutedEventArgs e) { e.Handled = true; UserAddEditMode = "edit"; userEdit = new DAL.User(); userEdit = (DAL.User)lbUsers.SelectedItem; tbUserPassword.Password = userEdit.Password; gbAddEditUser.DataContext = userEdit; try { cbUserGroup.SelectedIndex = cbUserGroup.Items.IndexOf(userEdit.Groupid.ToString()); } catch (Exception ex) { } gbAddEditUser.Visibility = Visibility.Visible; tbLoginID.Focus(); }
private void btnAddUser_Click(object sender, System.Windows.RoutedEventArgs e) { e.Handled = true; UserAddEditMode = "add"; userEdit = new DAL.User(); tbUserPassword.Password = ""; gbAddEditUser.DataContext = userEdit; gbAddEditUser.Visibility = Visibility.Visible; tbLoginID.Focus(); }
private void PerformLogin(System.Windows.RoutedEventArgs e) { si.sie("PerformLogin"); DAL.RDB proxy = new DAL.RDB(); Busy("test"); try { tbLoginFailed.Visibility = Visibility.Collapsed; DAL.User _currentUser = new DAL.User(); _currentUser = proxy.VerifyLogin(tbUsername.Text, tbPassword.Password); if (_currentUser.Fullname == "failed") { userlevel = "none"; animationControl.StartStateTransition(); tbLoginFailed.Visibility = Visibility.Visible; tbUsername.Focus(); animationControl.AnimateStateTransition(); } else { userlevel = _currentUser.Groupid; animationControl.StartStateTransition(); SetupUserLevel(); tbLoginFailed.Visibility = Visibility.Collapsed; gridLogin.Visibility = Visibility.Collapsed; tbUserLoggedIn.Text = _currentUser.Fullname; tbLogout.Visibility = Visibility.Visible; spNavigation.IsEnabled = true; btnConfiguration_Click(this,e); animationControl.AnimateStateTransition(); FetchMediaCollection(); InitializeFTPTimer(); } } catch (Exception ex) { } NotBusy(); si.sil("PerformLogin"); CheckExpiry(); }
private void btnRemoveUser_Click(object sender, System.Windows.RoutedEventArgs e) { e.Handled = true; userEdit = new DAL.User(); userEdit = (DAL.User)lbUsers.SelectedItem; proxy.RemoveUser(userEdit); RefreshUserCollection(); }