private static TeamMembersModel PopulateModel(string skill) { using (XSkillsEntities1 entities = new XSkillsEntities1()) { TeamMembersModel model = new TeamMembersModel() { Members = (from c in entities.User_Profile where c.Skills.Contains(skill) || string.IsNullOrEmpty(skill) select c).ToList(), Skills = (from c in entities.User_Profile select new SelectListItem { Text = c.Skills, Value = c.Skills }).Distinct().ToList() }; return(model); } }
public async Task EditAsync(TeamMembersModel inputModel, string EmployeeCode = "") { try { if (EmployeeCode == "") { // Create new Record inputModel.AddedBy = "Admin"; inputModel.AddedOn = DateTime.Now; inputModel.UpdatedOn = DateTime.Now; inputModel.TeamMembersId = Guid.NewGuid(); await _MyCommand.AddOrEditWithStoredProcedure("insert_teamMembers", null, inputModel, "par_"); return; } // Edit record with specified EmployeeCode _MyCommand.Add_Parameter_WithValue("par_EmployeeCode", EmployeeCode); inputModel.EmployeeCode = EmployeeCode; var employee = await Task.Run(() => _MyCommand.Select_Table("select_teamMembers", CommandType.StoredProcedure)); if (employee == null) { throw new Exception("Employee not found with provided Employee Code"); } await _MyCommand.AddOrEditWithStoredProcedure("update_teamMembers", null, inputModel, "par_"); } catch (Exception ex) { throw new System.Exception( Common.Utilities.ErrorCodes.ProcessException(ex, "BAL", "bTeamMembers", "EditAsync")); } finally { Close_MyDbContext(); } }
// Builds the team object that will be passed to the view. TeamMembersModel MakeTeam(List <MemberModel> employees) { var employment = new Dictionary <string, int>(); var position = new Dictionary <string, int>(); var shift = new Dictionary <string, int>(); var department = new Dictionary <string, int>(); var manager = new Dictionary <string, int>(); // Pull data from the records that have come in. // Foreach is pulling all of the filter options. foreach (var employee in employees) { if (employment.ContainsKey(employee.EmploymentStatus)) { employment[employee.EmploymentStatus] += 1; } else { employment.Add(employee.EmploymentStatus, 1); } if (position.ContainsKey(employee.Position)) { position[employee.Position] += 1; } else { position.Add(employee.Position, 1); } if (shift.ContainsKey(employee.Shift)) { shift[employee.Shift] += 1; } else { shift.Add(employee.Shift, 1); } if (department.ContainsKey(employee.Department)) { department[employee.Department] += 1; } else { department.Add(employee.Department, 1); } if (manager.ContainsKey(employee.Manager)) { manager[employee.Manager] += 1; } else { manager.Add(employee.Manager, 1); } } var team = new TeamMembersModel() { Employees = employees, Employment = employment, Position = position, Shift = shift, Department = department, Manager = manager }; return(team); }
public ActionResult Index(string skills) { TeamMembersModel model = PopulateModel(skills); return(View(model)); }
// GET: TeamMembers public ActionResult Index() { TeamMembersModel model = PopulateModel(null); return(View(model)); }
public async Task Put(string employeeCode, [FromBody] TeamMembersModel model) { await _bITeamMembers.EditAsync(model, employeeCode); return; }
public async Task Post([FromBody] TeamMembersModel teamMembers) { await _bITeamMembers.EditAsync(teamMembers); return; }