public IActionResult Edit(EmployeeView model) { if (model.BirthDate >= DateTime.Now) { ModelState.AddModelError("BirthDate", "Не верная дата рождения"); } if (ModelState.IsValid) { if (model.id > 0) { var dbItem = _employeesData.GetById(model.id); if (ReferenceEquals(dbItem, null)) { return(NotFound()); // возвращаем результат 404 Not Found } dbItem.Name = model.Name; dbItem.Surname = model.Surname; dbItem.BirthDate = model.BirthDate; dbItem.Patronymic = model.Patronymic; } else { _employeesData.AddNew(model); } _employeesData.Commit(); return(RedirectToAction(nameof(Users))); } else { return(View(model)); } }
public IActionResult Edit(EmployeeView model) { if (model.Id > 0) // если есть Id, то редактируем модель { var dbItem = _employees.GetById(model.Id); if (ReferenceEquals(dbItem, null)) { return(NotFound());// возвращаем результат 404 Not Found } dbItem.FirstName = model.FirstName; dbItem.SurName = model.SurName; dbItem.Age = model.Age; dbItem.Patronymic = model.Patronymic; } else // иначе добавляем модель в список { _employees.AddNew(model); } _employees.Commit(); // станет актуальным позднее (когда добавим БД) return(RedirectToAction(nameof(Index))); }
public EmployeeView UpdateEmployee(int id, EmployeeView entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } var employee = _employees.SingleOrDefault(e => e.Id.Equals(id)); if (employee == null) { throw new InvalidOperationException("Employee not exists"); } employee.Age = entity.Age; employee.BirthDate = entity.BirthDate; employee.FirstName = entity.FirstName; employee.Patronymic = entity.Patronymic; employee.SurName = entity.SurName; employee.Position = entity.Position; employee.HireDate = entity.HireDate; return(employee); }
/// <summary> /// This method checks if username and password valid. /// </summary> /// <param name="password">User input for password.</param> public void LogInExecute(object password) { Password = (password as PasswordBox).Password; if (Username == ownerUsername && Password == ownerPassword) { OwnerView ownerView = new OwnerView(); ownerView.ShowDialog(); } else if (users.FindManager(Username, Password) != null) { Manager = users.FindManager(Username, Password); ManagerView managerView = new ManagerView(Manager); managerView.ShowDialog(); } else if (users.FindEmployee(Username, Password) != null) { EmployeeView employeeView = new EmployeeView(); employeeView.ShowDialog(); } else { MessageBox.Show("Wrong username or password. Please, try again.", "Notification"); } }
public void CalculatePaycheck() { int id = EmployeeView.RequestId(); Employee employee = _repository.GetById(id); if (employee != null) { CountryPaycheckCalculator calculator = CountryPaycheckCalculatorFatory.GetPaycheckCalculator(employee); if (calculator != null) { Paycheck paycheck = calculator.CalculatePayCheck(employee); EmployeeView.ShowPaycheck(paycheck); } else { EmployeeView.ShowMessage($"O país {employee.Country} não é suportado para cálculo de olerite."); } } else { EmployeeView.ShowMessage("Funcionário não encontrado."); } }
public GetEmployeeResponse GetEmployee(GetRequest request) { GetEmployeeResponse response = new GetEmployeeResponse(); try { Employee employee = new Employee(); EmployeeView employeeView = new EmployeeView(); employee = _employeeRepository.FindBy(request.ID); if (employee != null) { employeeView = employee.ConvertToEmployeeView(); } IList <PermitView> permits = new List <PermitView>(); if (employeeView.LoginName == "sa") { foreach (var permit in employeeView.Permissions) { permit.Guaranteed = true; permits.Add(permit); } employeeView.Permissions = permits; } response.EmployeeView = employeeView; response.Employee = employee; } catch (Exception ex) { } return(response); }
public void AddNewEmployee(EmployeeView employee) { using (var context = new CompanyContext()) { Employee emp = new Employee { Prefix = employee.CbEmpPrefix.Text, FirstName = employee.TbEmpFirstName.Text, LastName = employee.TbEmpLastName.Text, DateOfBirth = employee.DpEmpDateOfBirth.SelectedDate, Address = employee.TbEmpAddress.Text, ZipCode = employee.TbEmpZipCode.Text, City = employee.TbEmpCity.Text, Country = employee.TbEmpCountry.Text, Mail = employee.TbEmpMail.Text, PhoneNumber = employee.TbEmpPhone.Text, MobilePhone = employee.TbEmpMobile.Text, //HiredOn = employee.TbEmpHiredOn.SelectedDate, }; Console.WriteLine("Adding: " + emp.FirstName + " " + emp.LastName + " as new Employee"); //Log change context.Employees.Add(emp); context.SaveChanges(); } }
public IActionResult Edit(EmployeeView model) { if (model.Id > 0) { var dbItem = _employees.GetById(model.Id); if (ReferenceEquals(dbItem, null)) // Сравниваем dbItem и null { return(NotFound()); } dbItem.FirstName = model.FirstName; dbItem.SurName = model.SurName; dbItem.Age = model.Age; } else { _employees.AddNew(model); } _employees.Commit();// для добавления в базу данных return(RedirectToAction(nameof(Index))); }
// Views are loaded here via RelayCommand along with their view models and data services public MainViewModel(ICustomerListViewModel _customerListViewModel, ICustomerRepository _customerDataService, Func <ICustomerDetailViewModel> _customerDetailViewModel, IEmployeeRepository _employeeDataService, IEmployeeListViewModel _employeeListViewModel, Func <IEmployeeDetailViewModel> _employeeDetailViewModel, IEventAggregator _eventAggregator, IPatrolScheduleDataViewModel _patrolScheduleDataViewModel, IPatrolRepository _patrolRepository, Func <IPatrolScheduleDetailViewModel> _patrolScheduleDetailViewModel, IEmpScheduleReport empScheduleReport, ICustomersLookupReport customerLookupReport, ISearchViewModel _searchViewModel) { _custView = new CustomerView(_customerListViewModel, _customerDataService, _customerDetailViewModel, _eventAggregator); _employeeView = new EmployeeView(_employeeListViewModel, _employeeDataService, _employeeDetailViewModel, _eventAggregator); _scheduleView = new PatrolScheduleView(_patrolScheduleDataViewModel, _patrolRepository, _patrolScheduleDetailViewModel, _eventAggregator); _searchView = new SearchView(_searchViewModel); _empScheduleReport = empScheduleReport; _customerLookupReport = customerLookupReport; SelectCustomerView = new RelayCommand(() => SelectedView = _custView); SelectEmployeeView = new RelayCommand(() => SelectedView = _employeeView); SelectScheduleView = new RelayCommand(() => SelectedView = _scheduleView); SelectSearchView = new RelayCommand(() => SelectedView = _searchView); GenerateEmployeeSchedules = new RelayCommand(async() => await RunEmpScheduleReport()); GenerateCustomerReport = new RelayCommand(async() => await RunCustomerReport()); EmpSchedules = new ObservableCollection <EmpScheduleModel>(); Customers = new ObservableCollection <CustomerReportModel>(); ExitCommand = new RelayCommand(() => Shutdown()); }
public void SetEmployee(string id, EmployeeView employee) { serviceDao.updateEmployee(employee); }
public EmployeeViewModel(EmployeeView employeeView, vwEmployee employee) { this.employeeView = employeeView; this.employee = employee; }
public Clients.Dto.Employee FromView(Clients.Dto.Employee dto, EmployeeView view) { return(_mapper.Map <Clients.Dto.Employee>(view)); }
public EmployeeView Update(int id, [FromBody] EmployeeView model) => employeeService.Update(id, model);
public string AddUserToDB(string Name, string Email, string Mobile, string Designation, string SubscriberId, string UpdatedBy) { try { bool res = false; //if (!admMgr.GetUserExists(Email, Mobile, "")) //{ string userName = admMgr.GenerateUserName(); var user = new ApplicationUser { UserName = userName, Email = Email, PhoneNumber = Mobile, EmailConfirmed = true }; var result = UserManager.Create(user, "changeme"); if (result.Succeeded) { //string ModuleAccess = "EMS"; string RoleId = "Employee"; //string Department = "FAC"; //bool ManagerLevel = false; var status = UserManager.AddToRole(user.Id, RoleId); string UserId = User.Identity.GetUserId(); var userDetail = generic.GetUserDetail(UserId); if (status.Succeeded) { // userId, employeeId, emplanelled, name, dob, gender, maritalStatus, alternateContact, alternateEmail, nationality, subscriberId, departmentId, // managerLevel, reportingAuthority, updatedBy, updatedOn, deactivated, fatherName, spouseName, emergencyContactName, // emergencyContactNumber, bloodGroup, physicallyChallenged, location, marriageDate, designationId) EmployeeView emp = new EmployeeView(); emp.UserId = user.Id; emp.EmployeeId = ""; emp.Emplanelled = false; emp.Name = Name; emp.Gender = ""; emp.DOB = DateTime.Now; emp.MaritalStatus = ""; emp.AlternateEmail = ""; emp.Nationality = ""; emp.DepartmentId = "FAC"; emp.ReportingAuthority = userDetail.SubscriberId; emp.UpdatedOn = DateTime.Now; emp.Deactivated = false; emp.FatherName = ""; emp.SpouseName = ""; emp.EmergencyContactName = ""; emp.EmergencyContactNumber = ""; emp.BloodGroup = ""; emp.Location = ""; emp.PhysicallyChallenged = false; emp.MarriageDate = DateTime.Now; emp.DesignationId = 64; emp.UpdatedBy = userDetail.SubscriberId; res = admMgr.AddEmployee(emp, userDetail.SubscriberId, UserId); var subscriberDetail = cms.GetCorporateProfile(SubscriberId).FirstOrDefault(); if (res) { SuccessCount++; Object[] data = new Object[8]; data[0] = Name; data[1] = Email; data[2] = Mobile; data[3] = result.Succeeded; //await SendEmailConfirmationTokenAsync(subscriberDetail.Name, user.Id, "Account activation", userName, Mobile, Name); } else { Object[] data = new Object[8]; data[0] = Name; data[1] = Email; data[2] = Mobile; data[3] = "Error"; resultedTable.Rows.Add(data); } } } else { FailureCount++; Object[] data = new Object[8]; data[0] = Name; data[1] = Email; data[2] = Mobile; data[3] = result.Succeeded; int i = 4; foreach (string err in result.Errors) { data[i] = err; i++; } resultedTable.Rows.Add(data); } //} //else //{ // FailureCount++; // Object[] data = new Object[8]; // data[0] = Name; // data[1] = Email; // data[2] = Mobile; // data[3] = "Failure"; // data[4] = "Email or Phone Number or Employee Code already exists"; // resultedTable.Rows.Add(data); //} } catch (Exception ex) { FailureCount++; Object[] data = new Object[8]; data[0] = Name; data[1] = Email; data[2] = Mobile; data[3] = "Failed"; data[4] = ex.Message; resultedTable.Rows.Add(data); } return("Result"); //return Json("Result", JsonRequestBehavior.AllowGet); }
public void AddNew(EmployeeView model) { var url = $"{ServiceAddress}"; Post(url, model); }
public void Add(EmployeeView Employee) => Post(_ServiceAddress, Employee);
public EmployeeView Edit(int id, EmployeeView Employee) { var response = Put($"{_ServiceAddress}/{id}", Employee); return(response.Content.ReadAsAsync <EmployeeView>().Result); }
public EmployeeView UpdateEmployee(int id, [FromBody] EmployeeView entity) { return(_employeeData.UpdateEmployee(id, entity)); }
public EmployeeViewModel(EmployeeView mainOpen) { main = mainOpen; AllOrders = GetAllOrders(); }
public EmployeeViewModel(EmployeeView employeeView, vwEmployee employee) { this.employeeView = employeeView; this.employee = employee; ReportList = reports.GetAllEmployeeReports(employee.EmployeeID); }
public void AddNew([FromBody] EmployeeView model) => employeeService.AddNew(model);
public void AddNew(EmployeeView model) { string url = $"{ServiceAddress}"; Post <EmployeeView>(url, value: model); }
public EmployeeView ToView(Clients.Dto.Employee dto, EmployeeView view) { return(_mapper.Map <EmployeeView>(dto)); }
public EmployeeViewModel(EmployeeView employeeViewOpen) { employeeView = employeeViewOpen; service = new PizzeriaService(); OrderList = service.GetOrders(); }
public EmployeeViewModel(EmployeeView employeeView) { this.employeeView = employeeView; employee = new vwEmployee(); }
public static Employee ConvertToEmployee( this EmployeeView employeeView) { return(Mapper.Map <EmployeeView, Employee>(employeeView)); }
public void AddNew(EmployeeView model) { model.Id = _employees.Max(x => x.Id) + 1; _employees.Add(model); }
public void AddNew(EmployeeView model) => Post(_ServiceAddress, model);
public EmployeeValidator(EmployeeView model) : base(model) { }
public EmployeeView Update(int id, EmployeeView employee) => Put <EmployeeView>($"{_ServiceAddress}/{id}", employee) .Content.ReadAsAsync <EmployeeView>() .Result;