public ActionResult AssignDepartment(AssignDepartmentViewModel viewModel) { DepartmentBL departmentBL = new DepartmentBL(); AssignDepartmentViewModel assignDepartmentViewModel = new AssignDepartmentViewModel(); assignDepartmentViewModel.Departments = new SelectList(departmentBL.GetActiveDepartments(), "DepartmentId", "DepartmentName", 1); assignDepartmentViewModel.UserPersonalInformationId = viewModel.UserPersonalInformationId; UserPersonalInformation fromDB = employeeBL.GetEmployeesById(viewModel.UserPersonalInformationId); if (ModelState.IsValid) { if (viewModel.DepartmentId > 0) { employeeBL.UpdateEmployeeDepartment(viewModel.UserPersonalInformationId, viewModel.DepartmentId); } else { ModelState.AddModelError("", "Error"); return(View(assignDepartmentViewModel)); } } else { ModelState.AddModelError("", "Error."); return(View(assignDepartmentViewModel)); } return(RedirectToAction("Employees", "Home")); }
protected static void RegisterWithValues(PALEntities db, string UserName, string Password, string EMail) { string Sha1Password = GetSha1HashData(Password); UserRegistration newUser = new UserRegistration { UserName = UserName, UserPassword = Sha1Password, UserEMail = EMail }; db.UserRegistrations.Add(newUser); db.SaveChanges(); ViewModel.ID = newUser.ID; UserPersonalInformation newUserPersonalInfo = new UserPersonalInformation { AvatarPicture = "http://i.imgur.com/xTMBZYr.jpg", UserRegID = ViewModel.ID }; db.SaveChanges(); db.UserPersonalInformations.Add(newUserPersonalInfo); UserGameInformation newUserGameInfo = new UserGameInformation { UserRegID = ViewModel.ID }; db.UserGameInformations.Add(newUserGameInfo); db.SaveChanges(); }
private void SaveChanges(object sender, RoutedEventArgs e) { PALEntities dataContex = new PALEntities(); UserPersonalInformation userPersonalInfo = GetUserById(dataContex, ViewModels.ViewModel.ID); if (!(string.IsNullOrEmpty(CityNameTextBox.Text) && string.IsNullOrWhiteSpace(CityNameTextBox.Text))) { userPersonalInfo.CityName = CityNameTextBox.Text; } if (!(string.IsNullOrEmpty(SchoolNameTextBox.Text) && string.IsNullOrWhiteSpace(SchoolNameTextBox.Text))) { userPersonalInfo.SchoolName = SchoolNameTextBox.Text; } if (!(string.IsNullOrEmpty(YearsOldTextBox.Text) && string.IsNullOrWhiteSpace(YearsOldTextBox.Text))) { userPersonalInfo.YearsOld = YearsOldTextBox.Text; } if (!(ClassComboBox.SelectedIndex < 0)) { ComboBoxItem cbItem = (ComboBoxItem)ClassComboBox.SelectedItem; userPersonalInfo.Class = cbItem.Content.ToString(); } if (!(SexComboBox.SelectedIndex < 0)) { //var editt = (TextBox)SexComboBox.Template.FindName("ClassComboBox", SexComboBox); ComboBoxItem cbItem = (ComboBoxItem)SexComboBox.SelectedItem; userPersonalInfo.Sex = cbItem.Content.ToString(); } dataContex.SaveChanges(); Switcher.Switch(Switcher.ProfileContentSwitcher, new ProfileContent()); }
public EmployeeListModel GetEmployee(int id) { EmployeeListModel viewModel = new EmployeeListModel(); UserPersonalInformation fromDB = GetEmployeesById(id); DepartmentBL department = new DepartmentBL(); bool active = false; if (fromDB.Active > 0) { active = true; } if (fromDB != null) { viewModel = new EmployeeListModel(); viewModel.Active = active; viewModel.Address = fromDB.Address; viewModel.EmployeeId = fromDB.EmployeeId; viewModel.FirstName = fromDB.FirstName; viewModel.LastName = fromDB.LastName; viewModel.Position = fromDB.Position; viewModel.BasicPay = fromDB.BasicPay; viewModel.UserPersonalInformationID = fromDB.UserPersonalInformationId; if (fromDB.DepartmentId > 0) { viewModel.Department = department.GetDepartmentById(fromDB.DepartmentId).DepartmentName; } } return(viewModel); }
public void InsertEmployee(UserPersonalInformation toDB) { using (var db = new PayrollEntities()) { db.UserPersonalInformations.Add(toDB); db.SaveChanges(); } }
public void FillUserPersonalInformationProperties(OrderInformationViewModel model, ref User user) { UserPersonalInformation userPersonalInformation = new UserPersonalInformation() { Name = model.Name, Surname = model.Surname, PhoneNumber = model.PhoneNumber, }; user.UserPersonalInformation = userPersonalInformation; }
public void FillUserPersonalInformationProperties(RegisterViewModel model, User user) { UserPersonalInformation userPersonalInformation = new UserPersonalInformation() { Name = model.Name, Surname = model.Surname, PhoneNumber = model.PhoneNumber }; user.UserPersonalInformation = userPersonalInformation; }
public void CreateEmployee(EmployeeListModel viewModel) { UserPersonalInformation toDB = new UserPersonalInformation(); toDB.Active = 1; toDB.Address = viewModel.Address; toDB.EmployeeId = viewModel.EmployeeId; toDB.FirstName = viewModel.FirstName; toDB.LastName = viewModel.LastName; toDB.Position = viewModel.Position; toDB.BasicPay = viewModel.BasicPay; InsertEmployee(toDB); }
public void UpdateEmployee(UserPersonalInformation userPersonalInformation) { using (var db = new PayrollEntities()) { var result = db.UserPersonalInformations.SingleOrDefault(b => b.UserPersonalInformationId == userPersonalInformation.UserPersonalInformationId); if (result != null) { result.Active = userPersonalInformation.Active; result.EmployeeId = userPersonalInformation.EmployeeId; result.Address = userPersonalInformation.Address; result.FirstName = userPersonalInformation.FirstName; result.LastName = userPersonalInformation.LastName; result.Position = userPersonalInformation.Position; result.BasicPay = userPersonalInformation.BasicPay; db.SaveChanges(); } } }
public void UpdateEmployee(EmployeeListModel viewModel) { int active = 0; if (viewModel.Active) { active = 1; } UserPersonalInformation toDB = new UserPersonalInformation(); toDB.Active = active; toDB.Address = viewModel.Address; toDB.EmployeeId = viewModel.EmployeeId; toDB.FirstName = viewModel.FirstName; toDB.LastName = viewModel.LastName; toDB.Position = viewModel.Position; toDB.BasicPay = viewModel.BasicPay; toDB.UserPersonalInformationId = viewModel.UserPersonalInformationID; UpdateEmployee(toDB); }
private void EdditPicture(object sender, MouseButtonEventArgs e) { OpenFileDialog op = new OpenFileDialog(); op.Title = "Избери изображение"; op.Filter = "All supported graphics|*.jpg;*.jpeg;*.png|" + "JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|" + "Portable Network Graphic (*.png)|*.png"; if (op.ShowDialog() == true) { string url = op.FileName; string uploadedImageURL = UploadImage(url); if (!string.IsNullOrEmpty(uploadedImageURL)) { PALEntities dataContex = new PALEntities(); UserPersonalInformation userPersonalInfo = GetUserById(dataContex, ViewModels.ViewModel.ID); userPersonalInfo.AvatarPicture = uploadedImageURL; dataContex.SaveChanges(); ImageBrush.ImageSource = new BitmapImage(new Uri(uploadedImageURL)); } } }
public List <AssignedEmployeeIncomesViewModel> AssignIncome(int id, out string fullName) { List <AssignedEmployeeIncomesViewModel> assignEmployeeIncomeViewModelList = new List <AssignedEmployeeIncomesViewModel>(); IncomeBL incomeBL = new IncomeBL(); Income income = new Income(); AssingedEmployeeIncomeBL assingedEmployeeIncomeBL = new AssingedEmployeeIncomeBL(); AssignedEmployeeIncomesViewModel assignEmployeeIncomeViewModel = new AssignedEmployeeIncomesViewModel(); UserPersonalInformation employee = GetEmployeesById(id); fullName = employee.FirstName + " " + employee.LastName; List <AssignedEmployeeIncome> fromDB = assingedEmployeeIncomeBL.GetAssignedEmployeeIncomes(id); if (fromDB != null) { foreach (var item in fromDB) { assignEmployeeIncomeViewModel = new AssignedEmployeeIncomesViewModel(); assignEmployeeIncomeViewModel.Name = fullName; assignEmployeeIncomeViewModel.AssignedEmployeeIncomeId = item.AssignedEmployeeIncomeID; //assignEmployeeIncomeViewModel.CustomIncomeAmount = item.CustomAmount; assignEmployeeIncomeViewModel.IncomeAmount = item.IncomeAmount; assignEmployeeIncomeViewModel.IncomeId = item.IncomeId; income = incomeBL.GetIncomesById(item.IncomeId); assignEmployeeIncomeViewModel.IncomeName = income.IncomeName; assignEmployeeIncomeViewModel.UserPersonalInformationId = item.UserPersonalInformationID; assignEmployeeIncomeViewModelList.Add(assignEmployeeIncomeViewModel); } } return(assignEmployeeIncomeViewModelList); }
public List <AssignedEmployeeDeductionsViewModel> AssignDeduction(int id, out string fullName) { List <AssignedEmployeeDeductionsViewModel> assignEmployeeDeductionsViewModelList = new List <AssignedEmployeeDeductionsViewModel>(); DeductionBL deductionBL = new DeductionBL(); Deduction deduction = new Deduction(); AssignedEmployeeDeductionBL assingedEmployeeDeductionBL = new AssignedEmployeeDeductionBL(); AssignedEmployeeDeductionsViewModel assignEmployeeDeductionViewModel = new AssignedEmployeeDeductionsViewModel(); UserPersonalInformation employee = GetEmployeesById(id); fullName = employee.FirstName + " " + employee.LastName; List <AssignedEmployeeDeduction> fromDB = assingedEmployeeDeductionBL.GetAssignedEmployeeDeductions(id); if (fromDB != null) { foreach (var item in fromDB) { assignEmployeeDeductionViewModel = new AssignedEmployeeDeductionsViewModel(); assignEmployeeDeductionViewModel.Name = fullName; assignEmployeeDeductionViewModel.AssignedEmployeeDeductionsId = item.AssignedEmployeeDeductionID; //assignEmployeeDeductionViewModel.CustomIncomeAmount = item.CustomAmount; assignEmployeeDeductionViewModel.DeductionAmount = item.DeductionAmount; assignEmployeeDeductionViewModel.DeductionId = item.DeductionId; deduction = deductionBL.GetDeductionById(item.DeductionId); assignEmployeeDeductionViewModel.DeductionName = deduction.DeductionName; assignEmployeeDeductionViewModel.UserPersonalInformationId = item.UserPersonalInformationID; assignEmployeeDeductionsViewModelList.Add(assignEmployeeDeductionViewModel); } } return(assignEmployeeDeductionsViewModelList); }
public ActionResult AssignDepartment(int id) { DepartmentBL departmentBL = new DepartmentBL(); AssignDepartmentViewModel assignDepartmentViewModel = new AssignDepartmentViewModel(); assignDepartmentViewModel.Departments = new SelectList(departmentBL.GetActiveDepartments(), "DepartmentId", "DepartmentName", 1); assignDepartmentViewModel.UserPersonalInformationId = id; UserPersonalInformation fromDB = employeeBL.GetEmployeesById(id); if (fromDB != null) { if (fromDB.DepartmentId > 0) { assignDepartmentViewModel.SelectedDepartment = departmentBL.GetDepartmentById(fromDB.DepartmentId).DepartmentName; } else { assignDepartmentViewModel.SelectedDepartment = "None Selected"; } } return(View(assignDepartmentViewModel)); }
private UserPersonalInformation GetUserById(PALEntities dataContex, int id) { UserPersonalInformation userPersonalInfo = dataContex.UserPersonalInformations.FirstOrDefault(p => p.UserRegID == id); return(userPersonalInfo); }