public IActionResult Delete(int id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { EmployeeTraining EmployeeTraining = context.EmployeeTraining.Single(u => u.EmployeeTrainingId == id); if (EmployeeTraining == null) { return(NotFound()); } context.EmployeeTraining.Remove(EmployeeTraining); context.SaveChanges(); return(Ok()); } catch (System.InvalidOperationException) { return(NotFound()); } }
// POST api/values public IActionResult Post([FromBody] EmployeeTraining EmployeeTraining) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } context.EmployeeTraining.Add(EmployeeTraining); try { context.SaveChanges(); } catch (DbUpdateException) { if (EmployeeTrainingExists(EmployeeTraining.EmployeeTrainingId)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } return(Ok(EmployeeTraining)); }
public void gridView_RowCommand(Object sender, GridViewCommandEventArgs e) { using (var context = new DatabaseContext()) { if (e.CommandName == "Nominate") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow selectedRow = gridView.Rows[index]; TableCell employeeNumber = selectedRow.Cells[0]; string empNo = employeeNumber.Text; var selectTrain = context.Trainings.FirstOrDefault(c => c.TrainingTitle == cmbTraining.Text); if (selectTrain != null) { EmployeeTraining empTrain = new EmployeeTraining() { EmployeeNumber = empNo, Status = "PENDING", TrainingId = selectTrain.TrainingId }; context.EmployeeTrainings.Add(empTrain); context.SaveChanges(); Page.ClientScript.RegisterStartupScript(this.GetType(), "scriptkey", "<script>alert('The selected employee's status is now PENDING.');</script>"); Refresh(); } } } }
public IActionResult AddTraining(AddTrainingViewModel model) { if (ModelState.IsValid) { EmployeeTraining newTraining = new EmployeeTraining { EmployeeId = model.EmployeeId, Name = model.Name, Location = model.Location, Duration = model.Duration, Provider = model.Provider, Start = model.Start, Finish = model.Finish, Notes = model.Notes }; _employeeRepository.AddEmpTraining(newTraining); var successMessage = "Training Info Created Successfully. Name: " + newTraining.EmployeeId; TempData["successAlert"] = successMessage; //return View(successMessage, ""); return(PartialView("_PartialMessage")); } return(View()); }
private void SubmitTraining(object sender, RoutedEventArgs e) { if (TrainingDate.SelectedDate != null) { int employeePK = Int32.Parse(employeeID.Text); var employee = db.Employees.FirstOrDefault(a => a.EmployeePK == employeePK); EmployeeTraining empTrain = new EmployeeTraining(); empTrain.FullName = employee.FirstName + " " + employee.LastName; empTrain.UserName = employee.UserName; empTrain.Training = TrainingType.Text; empTrain.DateOfTraining = TrainingDate.SelectedDate; empTrain.TimeOfTraining = TrainingTime.SelectedTime; empTrain.TrainingStatus = "Pending"; db.EmployeeTrainings.Add(empTrain); Notification notification = new Notification(); notification.NotificationToWho = empTrain.UserName; notification.Message = "You have a new training (" + empTrain.Training + " ) on " + empTrain.DateOfTraining; db.Notifications.Add(notification); db.SaveChanges(); TrainingList.ItemsSource = db.EmployeeTrainings.Where(a => a.UserName == employee.UserName).ToList(); } else { MessageBox.Show("Select Date"); } }
public IActionResult Post([FromBody] EmployeeTraining employee_training) { if (!ModelState.IsValid) { //if not valid data according to conditions then return the error return(BadRequest(ModelState)); } //adds the employee training relationship to the joiner table _context.EmployeeTraining.Add(employee_training); try { _context.SaveChanges(); } catch (DbUpdateException) { if (EmployeeTrainingExists(employee_training.EmployeeTrainingId)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } //returns the employee/training program relationship that was just added return(CreatedAtRoute("GetSingleEmployeeTraining", new { id = employee_training.EmployeeTrainingId }, employee_training)); }
public ActionResult Add(BindEmployeeTrainingViewModel arv) { SqlLiteContext context = new SqlLiteContext(); for (int i = 0; i < arv.Trainings.Count(); i++) { var employeeTraining = context.EmployeeTrainings.Where(a => a.EmployeeId == arv.Trainings[i].EmployeeId && a.TrainingId == arv.Trainings[i].TrainingId).FirstOrDefault(); if (arv.Trainings[i].Connected) { if (employeeTraining == null) { var et = new EmployeeTraining(); et.EmployeeId = arv.Trainings[i].EmployeeId; et.TrainingId = arv.Trainings[i].TrainingId; var entity = context.EmployeeTrainings.Add(et); entity.State = EntityState.Added; } } else { if (employeeTraining != null) { var entity = context.EmployeeTrainings.Remove(employeeTraining); entity.State = EntityState.Deleted; } } } context.SaveChanges(); return(RedirectToAction("Cv", "Home", new { id = arv.Trainings[0].EmployeeId })); }
// Create a new employeeTraining in the db and make sure we get a 200 OK status code back public async Task <EmployeeTraining> createEmployeeTraining(HttpClient client) { EmployeeTraining employeeTraining = new EmployeeTraining { EmployeeId = 1, TrainingProgramId = 1 }; string employeeTrainingAsJSON = JsonConvert.SerializeObject(employeeTraining); HttpResponseMessage response = await client.PostAsync( "api/employeeTraining", new StringContent(employeeTrainingAsJSON, Encoding.UTF8, "application/json") ); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); EmployeeTraining newEmployeeTraining = JsonConvert.DeserializeObject <EmployeeTraining>(responseBody); Assert.Equal(HttpStatusCode.Created, response.StatusCode); return(newEmployeeTraining); }
// Delete a employeeTraining join table in the database and make sure we get a no content status code back public async Task deleteEmployeeTraining(EmployeeTraining employeeTraining, HttpClient client) { HttpResponseMessage deleteResponse = await client.DeleteAsync($"api/employeeTraining/{employeeTraining.Id}"); deleteResponse.EnsureSuccessStatusCode(); Assert.Equal(HttpStatusCode.NoContent, deleteResponse.StatusCode); }
public void gridEmployee_RowCommand(Object sender, GridViewCommandEventArgs e) { using (var context = new DatabaseContext()) { if (e.CommandName == "Nominate") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow selectedRow = gridEmployee.Rows[index]; TableCell employeeNumber = selectedRow.Cells[0]; string empNo = employeeNumber.Text; var selectTrain = context.Trainings.FirstOrDefault(c => c.TrainingCode.ToLower() == txtTrainingCode.Text.ToLower()); if (selectTrain == null) { Page.ClientScript.RegisterStartupScript(this.GetType(), "scriptkey", "<script>alert('Search a training code first.');</script>"); } else { EmployeeTraining empTrain = new EmployeeTraining() { EmployeeNumber = empNo, Status = "APPROVED", TrainingId = selectTrain.TrainingId }; context.EmployeeTrainings.Add(empTrain); context.SaveChanges(); Page.ClientScript.RegisterStartupScript(this.GetType(), "scriptkey", "<script>alert('The selected employee's status is now APPROVED.');</script>"); } EmployeeReload(); } } }
public async Task <IActionResult> Post([FromRoute] int id, [FromBody] EmployeeTraining employeeTraining) { using (SqlConnection conn = Connection) { conn.Open(); using (SqlCommand cmd = conn.CreateCommand()) { bool exists = await EmployeeExist(employeeTraining.EmployeeId); if (exists) { cmd.CommandText = @"INSERT INTO EmployeeTraining (EmployeeId, TrainingProgramId) OUTPUT INSERTED.Id VALUES (@employeeId, @trainingProgramId)"; cmd.Parameters.Add(new SqlParameter("@employeeId", employeeTraining.EmployeeId)); cmd.Parameters.Add(new SqlParameter("@trainingProgramId", id)); var newId = (int)await cmd.ExecuteScalarAsync(); employeeTraining.Id = newId; return(Ok(employeeTraining)); } else { return(BadRequest($"No Employee with Id of {employeeTraining.EmployeeId}")); } } } }
//public ActionResult Create(EmployeeEditViewModel employee) public ActionResult Assign(EmployeeTraining employeeTraining, EmployeeTrainingAssignViewModel employee) { try //debug here { using (SqlConnection conn = Connection) { conn.Open(); using (SqlCommand cmd = conn.CreateCommand()) { cmd.CommandText = @"INSERT INTO EmployeeTraining (TrainingProgramId, EmployeeId) OUTPUT INSERTED.Id VALUES (@TrainingProgramId, @EmployeeId)"; cmd.Parameters.Add(new SqlParameter("@TrainingProgramId", employeeTraining.TrainingProgramId)); cmd.Parameters.Add(new SqlParameter("@EmployeeId", employee.Id)); var id = (int)cmd.ExecuteScalar(); //employeeTraining.EmployeeId = id; // this sends you back to index after created return(RedirectToAction("Details", new { employee.Id })); } } } catch (Exception ex) { // debug here return(View()); } }
public async Task <IActionResult> RemoveEmployeeBenefit(int EmployeeId, int TrainingId) { EmployeeTraining employeeTraining = await _repo.Get(EmployeeId, TrainingId); _repo.RemoveEmployeeTraining(employeeTraining); await _unitofwork.CompleteAsync(); return(Ok(EmployeeId)); }
public bool DeleteTraining(int Id, int userId) { EmployeeTraining Training = _db.EmployeeTrainings.Where(x => x.Id == Id).FirstOrDefault(); Training.Archived = true; Training.LastModifiedDate = DateTime.Now; Training.UserIDLastModifiedBy = userId; _db.SaveChanges(); return(true); }
public async Task <IActionResult> Edit(int id, EmployeeEditViewModel model) { if (id != model.Employee.EmployeeId) { return(NotFound()); } if (ModelState.IsValid) { try { // Update employee information _context.Update(model.Employee); // Remove all employee training sessions first List <EmployeeTraining> sessions = await _context.EmployeeTraining .Where(t => t.EmployeeId == id).ToListAsync(); foreach (var session in sessions) { _context.Remove(session); } // Add selected training sessions if (model.SelectedSessions.Count > 0) { foreach (int sessionId in model.SelectedSessions) { EmployeeTraining session = new EmployeeTraining() { EmployeeId = id, TrainingId = sessionId }; await _context.AddAsync(session); } } await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(model.Employee.EmployeeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(model)); }
public void gridEmployee_RowCommand(Object sender, GridViewCommandEventArgs e) { using (var context = new DatabaseContext()) { if (e.CommandName == "NominateEmployee") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow selectedRow = gridEmployee.Rows[index]; TableCell employeeNumber = selectedRow.Cells[0]; string empNo = employeeNumber.Text; var selectTrain = context.Trainings.FirstOrDefault(c => c.TrainingCode.ToLower() == txtTrainingCode.Text.ToLower()); if (selectTrain == null) { Page.ClientScript.RegisterStartupScript(this.GetType(), "scriptkey", "<script>alert('Search a training code first.');</script>"); } else { EmployeeTraining empTrain = new EmployeeTraining() { EmployeeNumber = empNo, Status = "PENDING", TrainingId = selectTrain.TrainingId }; context.EmployeeTrainings.Add(empTrain); context.SaveChanges(); Page.ClientScript.RegisterStartupScript(this.GetType(), "scriptkey", "<script>alert('The selected employee's status is now PENDING.');</script>"); int id = 0; var selectEmp = context.Employees.FirstOrDefault(c => c.EmployeeNumber == empNo); if (selectEmp != null) { id = selectEmp.DepartmentId; } if (id != 0) { var selectDept = context.Departments.FirstOrDefault(c => c.DepartmentId == id); if (selectDept != null) { var selectUser = context.Users.FirstOrDefault(c => c.DepartmentId == selectDept.DepartmentId && c.AccessType.ToLower() == "manager"); if (selectUser != null) { EMAIL(selectUser.Email); } } } } EmployeeReload(); } } }
public async Task <IActionResult> AddEmployeeBenefits(int employeeId, int TrainingId) { var EmployeeTraining = new EmployeeTraining { EmployeeId = employeeId, TrainingsId = TrainingId }; _repo.AddEmployeeTraining(EmployeeTraining); await _unitofwork.CompleteAsync(); return(StatusCode(201)); }
public IActionResult DeleteEmployeeTraining(int id) { EmployeeTraining employee_training = _context.EmployeeTraining.Single(p => p.EmployeeTrainingId == id); DateTime today = DateTime.Today; if (employee_training == null) { return(NotFound()); } _context.EmployeeTraining.Remove(employee_training); _context.SaveChanges(); return(Ok(employee_training)); }
public async Task Test_Create_EmployeeTraining() { using (var client = new APIClientProvider().Client) { // Create a new EmployeeTraining EmployeeTraining newEmployeeTraining = await createEmployeeTraining(client); // Make sure the info checks out Assert.Equal(1, newEmployeeTraining.EmployeeId); // Clean up after ourselves - delete EmployeeTraining! deleteEmployeeTraining(newEmployeeTraining, client); } }
public async Task <IActionResult> Post([FromBody] EmployeeTraining EmployeeTraining) { using (SqlConnection conn = Connection) { conn.Open(); using (SqlCommand cmd = conn.CreateCommand()) { cmd.CommandText = "INSERT INTO EmployeeTraining (EmployeeId, TrainingProgramId) OUTPUT INSERTED.Id VALUES (@EmployeeId, @TrainingProgramId)"; cmd.Parameters.Add(new SqlParameter("@EmployeeId", EmployeeTraining.EmployeeId)); cmd.Parameters.Add(new SqlParameter("@TrainingProgramId", EmployeeTraining.TrainingProgramId)); int newId = (int)cmd.ExecuteScalar(); EmployeeTraining.Id = newId; return(CreatedAtRoute("GetTrainingProgram", new { id = newId }, EmployeeTraining)); } } }
public static EmployeeTrainingRequest ToEntity(this EmployeeTraining request, Docs docs) => new EmployeeTrainingRequest { EmployeeTrainingId = request.EmployeeTrainingId, EmployeeTrainingName = request.EmployeeTrainingName, EmployeeId = request.EmployeeId, SiteId = request.SiteId, DateFrom = request.DateFrom, DateTo = request.DateTo, Comment = request.Comment, TrainingTypeId = request.TrainingTypeId, TrainingType = request.TrainingType, Employee = request.Employee, Site = request.Site, uri = docs == null?null:docs.DocumentPath, UserInsert = request.UserInsert, DateInsert = request.DateInsert, UserUpdate = request.UserUpdate, DateUpdate = request.DateUpdate, State = request.State, };
/// <summary> /// Saves the employee training. /// </summary> /// <param name="employeeTrainingView">The employee training view.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">employeeTrainingView</exception> public string saveEmployeeTraining(IEmployeeTrainingView employeeTrainingView) { if (employeeTrainingView == null) { throw new ArgumentNullException(nameof(employeeTrainingView)); } var result = string.Empty; var Trainee = new EmployeeTraining { TrainingId = employeeTrainingView.TrainingId, EmployeeId = employeeTrainingView.EmployeeId, SupervisorId = employeeTrainingView.SupervisorId, CompanyId = employeeTrainingView.CompanyId, IsApproved = null, IsActive = true, DateApproved = null, DateCreated = DateTime.Now, TrainingReportId = employeeTrainingView.TrainingReportId }; try { using ( var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS)) { dbContext.EmployeeTrainings.Add(Trainee); dbContext.SaveChanges(); } } catch (Exception e) { result = string.Format("SaveEmployeeTraining - {0} , {1}", e.Message, e.InnerException != null ? e.InnerException.Message : ""); } return(result); }
public IActionResult GetEmployeeTraining(int id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { EmployeeTraining employee_training = _context.EmployeeTraining.Single(p => p.EmployeeTrainingId == id); if (employee_training == null) { return(NotFound()); } return(Ok(employee_training)); } catch (System.InvalidOperationException ex) { return(NotFound()); } }
public async Task <IActionResult> Assign(int id, EmployeeTraining assign) { using (SqlConnection conn = Connection) { await conn.OpenAsync(); using (SqlCommand cmd = conn.CreateCommand()) { cmd.CommandText = @"INSERT INTO EmployeeTraining (EmployeeId, TrainingProgramId) VALUES (@employeeId, @trainingProgramId)"; cmd.Parameters.AddWithValue("@employeeId", id); cmd.Parameters.AddWithValue("@trainingProgramId", assign.TrainingProgramId); await cmd.ExecuteNonQueryAsync(); } } return(RedirectToAction(nameof(Details), new { id = id })); }
public IActionResult Post(int id, [FromBody] EmployeeTraining employeeTraining) { // Check if data matches the Model if (!ModelState.IsValid) { // return 404 if not matching return(BadRequest(ModelState)); } // Check the DB to ensure the tables Employee and Computer exist Employee employee = _context.Employee.Single(e => e.EmployeeId == id); TrainingProgram trainingProgram = _context.TrainingProgram.Single(tp => tp.TrainingProgramId == employeeTraining.TrainingProgramId); // return 404 if none found if (employee == null || trainingProgram == null) { return(NotFound()); } // add join to the table _context.EmployeeTraining.Add(employeeTraining); // save the changes _context.SaveChanges(); // return Created Route method return(CreatedAtRoute("GetSingleProduct", new { id = employeeTraining.EmployeeTrainingId }, employee)); }
public EmployeeTraining AddEmpTraining(EmployeeTraining training) { _context.EmployeeTrainings.Add(training); _context.SaveChanges(); return(training); }
public static IQueryable <EmployeeTrainingRequest> GetEmployeeTrainingByEmployeeIdAsync(this MastpenBitachonDbContext dbContext, EmployeeTraining entity) { string tableName = GetTableNameByType(dbContext, typeof(EmployeeTraining)).Result; // Get query from DbSet var query = from tr in dbContext.EmployeeTraining .Include(x => x.TrainingType).Include(x => x.Site) .Where(item => item.EmployeeId == entity.EmployeeId) .Where(item => item.TrainingTypeId == entity.TrainingTypeId) .AsQueryable() join docs in dbContext.Docs .Where(a => a.EntityTypeId == dbContext.EntityType.FirstOrDefault(item => item.EntityTypeName == tableName).EntityTypeId) .Where(a => a.DocumentTypeId == (int)DocumentType.Training) on tr.EmployeeTrainingId equals docs.EntityId into docs from x_docs in docs.DefaultIfEmpty() select tr.ToEntity(x_docs); return(query); }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new BangazonContext(serviceProvider.GetRequiredService <DbContextOptions <BangazonContext> >())) { if (context.Customer.Any()) { return; //db is already seeded } var customer = new Customer[] { new Customer { FirstName = "Gucci", LastName = "Mane" }, new Customer { FirstName = "Riff", LastName = "Raff" }, new Customer { FirstName = "Wacka Flocka", LastName = "Flame" } }; foreach (Customer i in customer) { context.Customer.Add(i); } context.SaveChanges(); var productsType = new ProductType[] { new ProductType { ProductTypeName = "Sports" }, new ProductType { ProductTypeName = "Toys" } }; foreach (ProductType i in productsType) { context.ProductType.Add(i); } context.SaveChanges(); var products = new Product[] { new Product { ProductTypeId = productsType.Single(s => s.ProductTypeName == "Sports").ProductTypeId, Price = 50.00, Title = "Baseball Glove", Description = "This glove will help you catch baseballs.", CustomerId = customer.Single(s => s.FirstName == "Wacka Flocka").CustomerId }, new Product { ProductTypeId = productsType.Single(s => s.ProductTypeName == "Sports").ProductTypeId, Price = 30.00, Title = "Basketball", Description = "Learn to dunk!", CustomerId = customer.Single(s => s.FirstName == "Riff").CustomerId }, new Product { ProductTypeId = productsType.Single(s => s.ProductTypeName == "Toys").ProductTypeId, Price = 10.00, Title = "Teddy Bear", Description = "Get it for the kids.", CustomerId = customer.Single(s => s.FirstName == "Wacka Flocka").CustomerId }, new Product { ProductTypeId = productsType.Single(s => s.ProductTypeName == "Toys").ProductTypeId, Price = 5.00, Title = "Coloring Book", Description = "Stay in the lines. Or don't. Its up to you.", CustomerId = customer.Single(s => s.FirstName == "Gucci").CustomerId } }; foreach (Product i in products) { context.Product.Add(i); } context.SaveChanges(); var paymentTypes = new PaymentType[] { new PaymentType { CustomerId = customer.Single(s => s.FirstName == "Gucci").CustomerId, AccountNumber = 2, PaymentTypeName = "Cash", }, new PaymentType { CustomerId = customer.Single(s => s.FirstName == "Riff").CustomerId, AccountNumber = 3, PaymentTypeName = "Visa", }, new PaymentType { CustomerId = customer.Single(s => s.FirstName == "Wacka Flocka").CustomerId, AccountNumber = 4, PaymentTypeName = "Mastercard", } }; foreach (PaymentType i in paymentTypes) { context.PaymentType.Add(i); } context.SaveChanges(); var orders = new Order[] { new Order { CustomerId = customer.Single(s => s.FirstName == "Wacka Flocka").CustomerId, // PaymentTypeId = paymentTypes.Single(s => s.PaymentTypeName == "Cash").PaymentTypeId, }, new Order { CustomerId = customer.Single(s => s.FirstName == "Riff").CustomerId, // PaymentTypeId = paymentTypes.Single(s => s.PaymentTypeName == "Visa").PaymentTypeId, }, new Order { CustomerId = customer.Single(s => s.FirstName == "Gucci").CustomerId, // PaymentTypeId = paymentTypes.Single(s => s.PaymentTypeName == "Mastercard").PaymentTypeId, } }; foreach (Order i in orders) { context.Order.Add(i); } context.SaveChanges(); var orderProduct = new OrderProduct[] { new OrderProduct { OrderId = 1, ProductId = products.Single(s => s.Title == "Baseball Glove").ProductId }, new OrderProduct { OrderId = 1, ProductId = products.Single(s => s.Title == "Teddy Bear").ProductId }, new OrderProduct { OrderId = 2, ProductId = products.Single(s => s.Title == "Basketball").ProductId }, new OrderProduct { OrderId = 3, ProductId = products.Single(s => s.Title == "Coloring Book").ProductId } }; foreach (OrderProduct i in orderProduct) { context.OrderProduct.Add(i); } context.SaveChanges(); var departments = new Department[] { new Department { DeptName = "Sporting Goods", ExpenseBudget = 1500 }, new Department { DeptName = "Toy Department", ExpenseBudget = 1250 } }; foreach (Department i in departments) { context.Department.Add(i); } context.SaveChanges(); var employees = new Employee[] { new Employee { EmployeeName = "A$AP Ferg", EmployeePhone = "212-555-1212", DepartmentId = departments.Single(s => s.DeptName == "Sporting Goods").DepartmentId, IsSupervisor = false, }, new Employee { EmployeeName = "A$AP Rocky", EmployeePhone = "212-555-1213", DepartmentId = departments.Single(s => s.DeptName == "Sporting Goods").DepartmentId, IsSupervisor = true, }, new Employee { EmployeeName = "A$AP Nast", EmployeePhone = "212-555-1214", DepartmentId = departments.Single(s => s.DeptName == "Toy Department").DepartmentId, IsSupervisor = false, } }; foreach (Employee i in employees) { context.Employee.Add(i); } context.SaveChanges(); var computers = new Computer[] { new Computer { ModelNumber = 123 }, new Computer { ModelNumber = 456 }, new Computer { ModelNumber = 789 } }; foreach (Computer i in computers) { context.Computer.Add(i); } context.SaveChanges(); var employeeComputers = new EmployeeComputer[] { new EmployeeComputer { ComputerId = computers.Single(s => s.ModelNumber == 123).ComputerId, EmployeeId = employees.Single(s => s.EmployeeName == "A$AP Nast").EmployeeId }, new EmployeeComputer { ComputerId = computers.Single(s => s.ModelNumber == 456).ComputerId, EmployeeId = employees.Single(s => s.EmployeeName == "A$AP Ferg").EmployeeId }, new EmployeeComputer { ComputerId = computers.Single(s => s.ModelNumber == 123).ComputerId, EmployeeId = employees.Single(s => s.EmployeeName == "A$AP Rocky").EmployeeId } }; foreach (EmployeeComputer i in employeeComputers) { context.EmployeeComputer.Add(i); } context.SaveChanges(); var training = new Training[] { new Training { StartDate = new DateTime(2017, 08, 01), EndDate = new DateTime(2017, 08, 07), Name = "Computer Training", MaxAttendees = 25 }, new Training { StartDate = new DateTime(2017, 09, 01), EndDate = new DateTime(2017, 09, 07), Name = "Up Selling", MaxAttendees = 40 }, new Training { StartDate = new DateTime(2017, 09, 10), EndDate = new DateTime(2017, 09, 12), Name = "Sensitivity Traning", MaxAttendees = 6 } }; foreach (Training i in training) { context.Training.Add(i); } context.SaveChanges(); var employeeTrainings = new EmployeeTraining[] { new EmployeeTraining { TrainingId = training.Single(s => s.Name == "Computer Training").TrainingId, EmployeeId = employees.Single(s => s.EmployeeName == "A$AP Nast").EmployeeId }, new EmployeeTraining { TrainingId = training.Single(s => s.Name == "Up Selling").TrainingId, EmployeeId = employees.Single(s => s.EmployeeName == "A$AP Ferg").EmployeeId }, new EmployeeTraining { TrainingId = training.Single(s => s.Name == "Sensitivity Traning").TrainingId, EmployeeId = employees.Single(s => s.EmployeeName == "A$AP Rocky").EmployeeId } }; foreach (EmployeeTraining i in employeeTrainings) { context.EmployeeTraining.Add(i); } context.SaveChanges(); } }
// Method runs on startup to initialize dummy data. public static void Initialize(IServiceProvider serviceProvider) { using (var context = new BanagazonWorkforceManagerContext(serviceProvider.GetRequiredService <DbContextOptions <BanagazonWorkforceManagerContext> >())) { // Look for any Employees. if (context.EmployeeTraining.Any()) { return; // DB has been seeded, the rest of this method doesn't need to run. } // Creating new instances of Department var Departments = new Department[] { new Department { Name = "Marketing" }, new Department { Name = "Sales" }, new Department { Name = "Tech Support" }, new Department { Name = "Human Resources" } }; // Adds each new Department into the context foreach (Department i in Departments) { context.Department.Add(i); } // Saves the Departments to the database context.SaveChanges(); // Creating new instances of Employee var Employees = new Employee[] { new Employee { FirstName = "Svetlana", LastName = "Smith", StartDate = new DateTime(1989, 8, 20), DepartmentID = 1 }, new Employee { FirstName = "Nigel", LastName = "Thornberry", StartDate = new DateTime(1974, 6, 20), DepartmentID = 1 }, new Employee { FirstName = "George", LastName = "Washington", StartDate = new DateTime(1776, 7, 4), DepartmentID = 1 }, new Employee { FirstName = "Tom", LastName = "Jerry", StartDate = new DateTime(1991, 9, 20), DepartmentID = 2 }, new Employee { FirstName = "Boris", LastName = "Johnson", StartDate = new DateTime(2015, 2, 4), DepartmentID = 2 }, new Employee { FirstName = "Mark", LastName = "Hamill", StartDate = new DateTime(1984, 12, 14), DepartmentID = 2 }, new Employee { FirstName = "George", LastName = "Dickel", StartDate = new DateTime(1919, 1, 3), DepartmentID = 3 }, new Employee { FirstName = "Jose", LastName = "Cuervo", StartDate = new DateTime(2013, 2, 28), DepartmentID = 3 }, new Employee { FirstName = "Alexander", LastName = "Hamilton", StartDate = new DateTime(1776, 7, 4), DepartmentID = 3 }, new Employee { FirstName = "Margaery", LastName = "Tyrell", StartDate = new DateTime(1991, 2, 23), DepartmentID = 4 }, new Employee { FirstName = "Podrick", LastName = "Payne", StartDate = new DateTime(2017, 6, 13), DepartmentID = 4 }, new Employee { FirstName = "Rickon", LastName = "Stark", StartDate = new DateTime(2004, 4, 14), DepartmentID = 4 } }; // Adds each new Employee into the context foreach (Employee i in Employees) { context.Employee.Add(i); } // Saves the Employees to the database context.SaveChanges(); // Creating new instances of TrainingProgram var TrainingPrograms = new TrainingProgram[] { new TrainingProgram { Name = "Scrum System: The Basics", Description = "Learn how to be productive during a sprint.", StartDate = new DateTime(2017, 12, 14), EndDate = new DateTime(2017, 12, 15), MaxAttendees = 4 }, new TrainingProgram { Name = "Mentor Partnership", Description = "Come and coach or be coached by others in the company.", StartDate = new DateTime(2017, 11, 12), EndDate = new DateTime(2017, 11, 14), MaxAttendees = 20 }, new TrainingProgram { Name = "2018 Orientation", Description = "We will discuss new company policies going into effect in 2018.", StartDate = new DateTime(2018, 1, 4), EndDate = new DateTime(2018, 1, 7), MaxAttendees = 8 }, new TrainingProgram { Name = "Modern Hiring Practices", Description = "How to conduct interviews in the modern era.", StartDate = new DateTime(2015, 2, 28), EndDate = new DateTime(2015, 3, 2), MaxAttendees = 120 }, new TrainingProgram { Name = "CPR Class", Description = "Best to be prepared.", StartDate = new DateTime(2016, 7, 12), EndDate = new DateTime(2016, 7, 18), MaxAttendees = 50 }, new TrainingProgram { Name = "Public Speaking Workshop", Description = "Always a handy skill to have.", StartDate = new DateTime(2017, 4, 25), EndDate = new DateTime(2017, 4, 28), MaxAttendees = 15 } }; foreach (TrainingProgram i in TrainingPrograms) { context.TrainingProgram.Add(i); } // Saves the TrainingPrograms to the database context.SaveChanges(); // Creating new instances of Computer var Computers = new Computer[] { new Computer { Make = "Macbook Pro 2015", Manufacturer = "Apple", DatePurchased = new DateTime(2015, 4, 13) }, new Computer { Make = "Macbook Pro 2016", Manufacturer = "Apple", DatePurchased = new DateTime(2016, 4, 1) }, new Computer { Make = "Macbook Pro 2017", Manufacturer = "Apple", DatePurchased = new DateTime(2017, 4, 15) }, new Computer { Make = "Thinkpad", Manufacturer = "Lenovo", DatePurchased = new DateTime(2016, 4, 15) }, new Computer { Make = "Yoga", Manufacturer = "Lenovo", DatePurchased = new DateTime(2016, 4, 15) }, new Computer { Make = "Inspiron", Manufacturer = "Dell", DatePurchased = new DateTime(2016, 4, 15) }, new Computer { Make = "Aspire", Manufacturer = "Acer", DatePurchased = new DateTime(2016, 4, 15) }, new Computer { Make = "Pavilion", Manufacturer = "HP", DatePurchased = new DateTime(2016, 4, 15) }, new Computer { Make = "Sense", Manufacturer = "Samsung", DatePurchased = new DateTime(2016, 4, 15) }, new Computer { Make = "Zenbook", Manufacturer = "Asus", DatePurchased = new DateTime(2016, 4, 15) }, new Computer { Make = "Travelmate", Manufacturer = "Acer", DatePurchased = new DateTime(2016, 4, 15) }, new Computer { Make = "Elitebook", Manufacturer = "HP", DatePurchased = new DateTime(2016, 4, 15) }, }; // Adds each new Computer into the context foreach (Computer i in Computers) { context.Computer.Add(i); } // Saves the Computers to the database context.SaveChanges(); var EmployeeComputers = new EmployeeComputer[] { new EmployeeComputer { EmployeeID = 1, ComputerID = 1, DateAssigned = new DateTime(2017, 4, 15), DateUnassigned = new DateTime(2017, 4, 16) }, new EmployeeComputer { EmployeeID = 2, ComputerID = 1, DateAssigned = new DateTime(2017, 4, 17), DateUnassigned = new DateTime(2017, 4, 18) }, new EmployeeComputer { EmployeeID = 3, ComputerID = 1, DateAssigned = new DateTime(2017, 4, 19), DateUnassigned = new DateTime(2017, 4, 20) }, new EmployeeComputer { EmployeeID = 4, ComputerID = 1, DateAssigned = new DateTime(2017, 4, 21), DateUnassigned = new DateTime(2017, 4, 22) }, new EmployeeComputer { EmployeeID = 5, ComputerID = 1, DateAssigned = new DateTime(2017, 4, 23), DateUnassigned = new DateTime(2017, 4, 24) }, new EmployeeComputer { EmployeeID = 6, ComputerID = 1, DateAssigned = new DateTime(2017, 4, 25), DateUnassigned = new DateTime(2017, 4, 26) }, new EmployeeComputer { EmployeeID = 7, ComputerID = 1, DateAssigned = new DateTime(2017, 4, 27), DateUnassigned = new DateTime(2017, 4, 28) }, new EmployeeComputer { EmployeeID = 8, ComputerID = 1, DateAssigned = new DateTime(2017, 4, 29), DateUnassigned = new DateTime(2017, 4, 30) }, new EmployeeComputer { EmployeeID = 9, ComputerID = 1, DateAssigned = new DateTime(2017, 4, 1), DateUnassigned = new DateTime(2017, 4, 2) }, new EmployeeComputer { EmployeeID = 10, ComputerID = 1, DateAssigned = new DateTime(2017, 4, 3), DateUnassigned = new DateTime(2017, 4, 4) }, new EmployeeComputer { EmployeeID = 11, ComputerID = 1, DateAssigned = new DateTime(2017, 4, 5), DateUnassigned = new DateTime(2017, 4, 6) }, new EmployeeComputer { EmployeeID = 12, ComputerID = 1, DateAssigned = new DateTime(2017, 4, 7), DateUnassigned = new DateTime(2017, 4, 8) }, new EmployeeComputer { EmployeeID = 1, ComputerID = 1, DateAssigned = new DateTime(2017, 5, 01) }, new EmployeeComputer { EmployeeID = 2, ComputerID = 2, DateAssigned = new DateTime(2017, 5, 01) }, new EmployeeComputer { EmployeeID = 3, ComputerID = 3, DateAssigned = new DateTime(2017, 5, 01) }, new EmployeeComputer { EmployeeID = 4, ComputerID = 4, DateAssigned = new DateTime(2017, 5, 01) }, new EmployeeComputer { EmployeeID = 5, ComputerID = 5, DateAssigned = new DateTime(2017, 5, 01) }, new EmployeeComputer { EmployeeID = 6, ComputerID = 6, DateAssigned = new DateTime(2017, 5, 01) }, new EmployeeComputer { EmployeeID = 7, ComputerID = 7, DateAssigned = new DateTime(2017, 5, 01) }, new EmployeeComputer { EmployeeID = 8, ComputerID = 8, DateAssigned = new DateTime(2017, 5, 01) } }; // Adds each new EmployeeComputer into the context foreach (EmployeeComputer i in EmployeeComputers) { context.EmployeeComputer.Add(i); } // Saves the Computers to the database context.SaveChanges(); // Creating new instances of EmployeeTraining var EmployeeTrainings = new EmployeeTraining[] { new EmployeeTraining { EmployeeID = 1, TrainingProgramID = 1 }, new EmployeeTraining { EmployeeID = 2, TrainingProgramID = 1 }, new EmployeeTraining { EmployeeID = 3, TrainingProgramID = 1 }, new EmployeeTraining { EmployeeID = 4, TrainingProgramID = 2 }, new EmployeeTraining { EmployeeID = 5, TrainingProgramID = 2 }, new EmployeeTraining { EmployeeID = 6, TrainingProgramID = 2 }, new EmployeeTraining { EmployeeID = 7, TrainingProgramID = 4 }, new EmployeeTraining { EmployeeID = 8, TrainingProgramID = 4 }, new EmployeeTraining { EmployeeID = 9, TrainingProgramID = 4 }, new EmployeeTraining { EmployeeID = 7, TrainingProgramID = 5 }, new EmployeeTraining { EmployeeID = 8, TrainingProgramID = 5 }, new EmployeeTraining { EmployeeID = 9, TrainingProgramID = 5 }, new EmployeeTraining { EmployeeID = 7, TrainingProgramID = 6 }, new EmployeeTraining { EmployeeID = 9, TrainingProgramID = 6 }, new EmployeeTraining { EmployeeID = 9, TrainingProgramID = 2 }, new EmployeeTraining { EmployeeID = 9, TrainingProgramID = 3 }, new EmployeeTraining { EmployeeID = 10, TrainingProgramID = 6 }, new EmployeeTraining { EmployeeID = 8, TrainingProgramID = 6 }, new EmployeeTraining { EmployeeID = 11, TrainingProgramID = 4 } }; // Adds each new EmployeeTraining into the context foreach (EmployeeTraining i in EmployeeTrainings) { context.EmployeeTraining.Add(i); } // Saves the EmployeeTraining to the database context.SaveChanges(); } }
public PartialViewResult GetNotificationDetailsByKey(int EmployeeID, string Header, int?DetailsId) { NotificationMethod _NotificationMethod = new NotificationMethod(); NotificationDetail _NotificationDetail = new NotificationDetail(); if (Header == "TimeSheet Request") { var data = _NotificationMethod.GetTimeSheetNotificationByKey(EmployeeID, DetailsId).FirstOrDefault(); if (data != null) { _NotificationDetail.EmployeeId = data.EmployeeId; _NotificationDetail.HeaderType = data.HeaderType; _NotificationDetail.Hours = data.Hours; _NotificationDetail.ProjectName = data.ProjectName; _NotificationDetail.Day = data.Day; _NotificationDetail.Date = data.Date; _NotificationDetail.CustomerName = data.CustomerName; _NotificationDetail.CostCode = data.CostCode; _NotificationDetail.AssetName = data.AssetName; var reportTodata = _db.EmployeeRelations.Where(x => x.IsActive == true && x.UserID == EmployeeID).FirstOrDefault(); var aspnetUserDetails = _db.AspNetUsers.Where(x => x.Archived == false && x.Id == EmployeeID).FirstOrDefault(); Employee_TimeSheet_Detail TimeSheetDetails = new Employee_TimeSheet_Detail(); TimeSheetDetails = _db.Employee_TimeSheet_Detail.Find(DetailsId); if (TimeSheetDetails != null && TimeSheetDetails.ApprovalStatus == "Pending") { _NotificationDetail.AppStatus = TimeSheetDetails.ApprovalStatus; } if (aspnetUserDetails != null && TimeSheetDetails != null) { if (aspnetUserDetails.HRResponsible == SessionProxy.UserId && aspnetUserDetails.HRResponsible != null) { TimeSheetDetails.IsReadHR = true; } if (aspnetUserDetails.AdditionalReportsto == SessionProxy.UserId) { TimeSheetDetails.IsReadAddRep = true; } if (TimeSheetDetails != null && reportTodata.Reportsto == SessionProxy.UserId) { TimeSheetDetails.IsRead = true; } _db.Entry(TimeSheetDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } } if (Header == "Training Request Worker") { var data = _NotificationMethod.getEmployeeTrainingById(Convert.ToInt32(DetailsId)).FirstOrDefault(); if (data != null) { _NotificationDetail.EmployeeId = data.EmployeeId; _NotificationDetail.HeaderType = "Training Request Worker"; _NotificationDetail.StartDate = Convert.ToString(data.StartDate); _NotificationDetail.EndDate = Convert.ToString(data.EndDate); _NotificationDetail.TrainingDescription = data.Description; EmployeeTraining trainingDetails = new EmployeeTraining(); trainingDetails = _db.EmployeeTrainings.Find(DetailsId); trainingDetails.IsReadWorker = true; _db.Entry(trainingDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } else if (Header == "Skill Added") { var data = _NotificationMethod.getEmployeeSkillById(Convert.ToInt32(DetailsId)).FirstOrDefault(); if (data != null) { _NotificationDetail.EmployeeId = data.EmployeeId; _NotificationDetail.HeaderType = "Skill Added"; if (data.GeneralSkillsName != "" && data.GeneralSkillsName != null) { int GenralSkillName = Convert.ToInt32(data.GeneralSkillsName); _NotificationDetail.generalSkill = _db.SkillSets.Where(x => x.Id == GenralSkillName).FirstOrDefault().Name; } else { _NotificationDetail.generalSkill = null; } if (data.TechnicalSkillsName != "" && data.TechnicalSkillsName != null) { int TechnSkillName = Convert.ToInt32(data.TechnicalSkillsName); _NotificationDetail.technicalskill = _db.SkillSets.Where(x => x.Id == TechnSkillName).FirstOrDefault().Name; } else { _NotificationDetail.technicalskill = null; } _NotificationDetail.StartDate = Convert.ToString(data.CreatedDate); Employee_Skills EmpSkillDetails = new Employee_Skills(); EmpSkillDetails = _db.Employee_Skills.Find(DetailsId); EmpSkillDetails.IsRead = true; _db.Entry(EmpSkillDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } else if (Header == "Scheduling Request") { var data = _NotificationMethod.GetScheduleNotificationByKey(EmployeeID, DetailsId).FirstOrDefault(); if (data != null) { _NotificationDetail.EmployeeId = data.EmployeeId; _NotificationDetail.HeaderType = data.HeaderType; _NotificationDetail.Hours = data.Hours; _NotificationDetail.ProjectName = data.Project; _NotificationDetail.CustomerName = data.Customer; _NotificationDetail.CostCode = data.AssetName; _NotificationDetail.StartDate = data.StartDate; _NotificationDetail.EndDate = data.EndDate; _NotificationDetail.Duration = data.duration; _NotificationDetail.AssetName = data.AssetName; var reportTodata = _db.EmployeeRelations.Where(x => x.IsActive == true && x.UserID == EmployeeID).FirstOrDefault(); var aspnetUserDetails = _db.AspNetUsers.Where(x => x.Archived == false && x.Id == EmployeeID).FirstOrDefault(); Employee_ProjectPlanner_Scheduling SchedulingDetails = new Employee_ProjectPlanner_Scheduling(); SchedulingDetails = _db.Employee_ProjectPlanner_Scheduling.Find(DetailsId); if (SchedulingDetails != null && SchedulingDetails.ApprovalStatus == "Pending") { _NotificationDetail.AppStatus = SchedulingDetails.ApprovalStatus; } if (aspnetUserDetails != null && SchedulingDetails != null) { if (aspnetUserDetails.HRResponsible == SessionProxy.UserId && aspnetUserDetails.HRResponsible != null) { SchedulingDetails.IsReadHR = true; } if (aspnetUserDetails.AdditionalReportsto == SessionProxy.UserId) { SchedulingDetails.IsReadAddRes = true; } if (SchedulingDetails != null && reportTodata.Reportsto == SessionProxy.UserId) { SchedulingDetails.IsRead = true; } _db.Entry(SchedulingDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } } else if (Header == "Travel Request") { var data = _NotificationMethod.GetTravelNotificationByKey(EmployeeID, DetailsId).FirstOrDefault(); if (data != null) { _NotificationDetail.EmployeeId = data.EmployeeId; _NotificationDetail.HeaderType = data.HeaderType; _NotificationDetail.TravelType = data.Type; _NotificationDetail.FromCountry = data.FromCountry; _NotificationDetail.FromTown = data.FromCity; _NotificationDetail.FromPlace = data.FromPlace; _NotificationDetail.ToCountry = data.ToCountry; _NotificationDetail.ToTown = data.ToCity; _NotificationDetail.Toplace = data.ToPlace; _NotificationDetail.StartDate = data.StartDate; _NotificationDetail.EndDate = data.EndDate; _NotificationDetail.Duration = data.Duration; _NotificationDetail.Hours = data.Hour; _NotificationDetail.CustomerName = data.CustomerName; _NotificationDetail.ProjectName = data.ProjectName; _NotificationDetail.CostCode = data.CostCode; _NotificationDetail.Function = ""; _NotificationDetail.Link = ""; var reportTodata = _db.EmployeeRelations.Where(x => x.IsActive == true && x.UserID == EmployeeID).FirstOrDefault(); var aspnetUserDetails = _db.AspNetUsers.Where(x => x.Archived == false && x.Id == EmployeeID).FirstOrDefault(); Employee_TravelLeave TravelLeaveDetails = new Employee_TravelLeave(); TravelLeaveDetails = _db.Employee_TravelLeave.Find(DetailsId); if (TravelLeaveDetails != null && TravelLeaveDetails.ApprovalStatus == "Pending") { _NotificationDetail.AppStatus = TravelLeaveDetails.ApprovalStatus; } if (aspnetUserDetails != null && TravelLeaveDetails != null) { if (aspnetUserDetails.HRResponsible == SessionProxy.UserId && aspnetUserDetails.HRResponsible != null) { TravelLeaveDetails.IsReadHR = true; } if (aspnetUserDetails.AdditionalReportsto == SessionProxy.UserId) { TravelLeaveDetails.IsReadAddReport = true; } if (TravelLeaveDetails != null && reportTodata.Reportsto == SessionProxy.UserId) { TravelLeaveDetails.IsRead = true; } _db.Entry(TravelLeaveDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } } else if (Header == "Annual Leave Request") { var data = _NotificationMethod.GetAnnualLeaveNotificationByKey(EmployeeID, DetailsId).FirstOrDefault(); if (data != null) { _NotificationDetail.EmployeeId = data.EmployeeId; _NotificationDetail.StartDate = data.StartDate; _NotificationDetail.EndDate = data.EndDate; _NotificationDetail.HeaderType = "Annual Leave Request"; _NotificationDetail.Duration = data.Duration; var reportTodata = _db.EmployeeRelations.Where(x => x.IsActive == true && x.UserID == EmployeeID).FirstOrDefault(); var aspnetUserDetails = _db.AspNetUsers.Where(x => x.Archived == false && x.Id == EmployeeID).FirstOrDefault(); Employee_AnualLeave AnualLeaveDetails = new Employee_AnualLeave(); AnualLeaveDetails = _db.Employee_AnualLeave.Find(DetailsId); if (AnualLeaveDetails != null && AnualLeaveDetails.ApprovalStatus == "Pending") { _NotificationDetail.AppStatus = AnualLeaveDetails.ApprovalStatus; } if (aspnetUserDetails != null && AnualLeaveDetails != null) { if (aspnetUserDetails.HRResponsible == SessionProxy.UserId && aspnetUserDetails.HRResponsible != null) { AnualLeaveDetails.IsReadHR = true; } if (aspnetUserDetails.AdditionalReportsto == SessionProxy.UserId) { AnualLeaveDetails.IsReadAddRep = true; } if (AnualLeaveDetails != null && reportTodata.Reportsto == SessionProxy.UserId) { AnualLeaveDetails.IsRead = true; } _db.Entry(AnualLeaveDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } } else if (Header == "Other Leave Request") { var data = _NotificationMethod.GetOtherLeaveNotificationByKey(EmployeeID, DetailsId).FirstOrDefault(); if (data != null) { _NotificationDetail.EmployeeId = data.EmployeeId; _NotificationDetail.HeaderType = data.HeaderType; _NotificationDetail.StartDate = data.StartDate; _NotificationDetail.EndDate = data.EndDate; _NotificationDetail.Duration = data.Duration; _NotificationDetail.Reason = data.Reason; var reportTodata = _db.EmployeeRelations.Where(x => x.IsActive == true && x.UserID == EmployeeID).FirstOrDefault(); var aspnetUserDetails = _db.AspNetUsers.Where(x => x.Archived == false && x.Id == EmployeeID).FirstOrDefault(); Employee_OtherLeave OtherLeaveDetails = new Employee_OtherLeave(); OtherLeaveDetails = _db.Employee_OtherLeave.Find(DetailsId); if (OtherLeaveDetails != null && OtherLeaveDetails.ApprovalStatus == "Pending") { _NotificationDetail.AppStatus = OtherLeaveDetails.ApprovalStatus; } if (aspnetUserDetails != null && OtherLeaveDetails != null) { if (aspnetUserDetails.HRResponsible == SessionProxy.UserId && aspnetUserDetails.HRResponsible != null) { OtherLeaveDetails.IsReadHR = true; } if (aspnetUserDetails.AdditionalReportsto == SessionProxy.UserId) { OtherLeaveDetails.IsReadAddRep = true; } if (OtherLeaveDetails != null && reportTodata.Reportsto == SessionProxy.UserId) { OtherLeaveDetails.IsRead = true; } _db.Entry(OtherLeaveDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } } else if (Header == "Maternity/Paternity Leave") { var data = _NotificationMethod.GetMaternityPatLeaveByKey(Convert.ToInt32(DetailsId)).FirstOrDefault(); if (data != null) { _NotificationDetail.EmployeeId = data.EmployeeID; _NotificationDetail.HeaderType = "Maternity/Paternity Leave"; _NotificationDetail.StartDate = Convert.ToString(data.ActualStartDate); _NotificationDetail.EndDate = Convert.ToString(data.ActualEndDate); _NotificationDetail.dueDate = Convert.ToString(data.DueDate); _NotificationDetail.Link = data.Link; var reportTodata = _db.EmployeeRelations.Where(x => x.IsActive == true && x.UserID == EmployeeID).FirstOrDefault(); var aspnetUserDetails = _db.AspNetUsers.Where(x => x.Archived == false && x.Id == EmployeeID).FirstOrDefault(); Employee_MaternityOrPaternityLeaves MatPatLeaveDetails = new Employee_MaternityOrPaternityLeaves(); MatPatLeaveDetails = _db.Employee_MaternityOrPaternityLeaves.Find(DetailsId); if (MatPatLeaveDetails != null && MatPatLeaveDetails.ApprovalStatus == "Pending") { _NotificationDetail.AppStatus = MatPatLeaveDetails.ApprovalStatus; } if (aspnetUserDetails != null && MatPatLeaveDetails != null) { if (aspnetUserDetails.HRResponsible == SessionProxy.UserId && aspnetUserDetails.HRResponsible != null) { MatPatLeaveDetails.IsReadHR = true; } if (aspnetUserDetails.AdditionalReportsto == SessionProxy.UserId) { MatPatLeaveDetails.IsReadAddRes = true; } if (MatPatLeaveDetails != null && reportTodata.Reportsto == SessionProxy.UserId) { MatPatLeaveDetails.IsRead = true; } _db.Entry(MatPatLeaveDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } } else if (Header == "Sick Leave") { var data = _NotificationMethod.getSickLeaveByKey(Convert.ToInt32(DetailsId)).FirstOrDefault(); if (data != null) { _NotificationDetail.EmployeeId = data.EmployeeId; _NotificationDetail.HeaderType = "Sick Leave Request"; _NotificationDetail.StartDate = Convert.ToString(data.StartDate); _NotificationDetail.EndDate = Convert.ToString(data.EndDate); _NotificationDetail.Duration = Convert.ToDecimal(data.DurationDays); _NotificationDetail.DoctConsulted = data.DoctorConsulted; _NotificationDetail.Paid = data.IsPaid; var reportTodata = _db.EmployeeRelations.Where(x => x.IsActive == true && x.UserID == EmployeeID).FirstOrDefault(); Employee_SickLeaves SickLeaveDetails = new Employee_SickLeaves(); SickLeaveDetails = _db.Employee_SickLeaves.Find(DetailsId); if (SickLeaveDetails != null && SickLeaveDetails.ApprovalStatus == "Pending") { _NotificationDetail.AppStatus = SickLeaveDetails.ApprovalStatus; } var aspnetUserDetails = _db.AspNetUsers.Where(x => x.Archived == false && x.Id == EmployeeID).FirstOrDefault(); if (aspnetUserDetails != null && SickLeaveDetails != null) { if (aspnetUserDetails.HRResponsible == SessionProxy.UserId && aspnetUserDetails.HRResponsible != null) { SickLeaveDetails.IsReadHR = true; } if (aspnetUserDetails.AdditionalReportsto == SessionProxy.UserId) { SickLeaveDetails.IsReadAddRep = true; } if (SickLeaveDetails != null && reportTodata.Reportsto == SessionProxy.UserId) { SickLeaveDetails.IsRead = true; } _db.Entry(SickLeaveDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } } else if (Header == "Training Request") { var data = _NotificationMethod.GetTrainingNotificationByKey(EmployeeID, DetailsId).FirstOrDefault(); if (data != null) { _NotificationDetail.EmployeeId = data.EmployeeId; _NotificationDetail.StartDate = data.StartDate; _NotificationDetail.EndDate = data.EndDate; _NotificationDetail.TrainingName = data.TrainingName; _NotificationDetail.Provider = data.Provider; if (data.Importance == 1) { _NotificationDetail.Importance = "Mandatory"; } else { _NotificationDetail.Importance = "Optional"; } _NotificationDetail.Cost = data.Cost; _NotificationDetail.Day = Convert.ToString(data.Days); _NotificationDetail.HeaderType = "Training Request"; EmployeeTraining EmployeeTraining = new EmployeeTraining(); EmployeeTraining = _db.EmployeeTrainings.Find(DetailsId); EmployeeTraining.IsRead = true; _db.Entry(EmployeeTraining).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } else if (Header == "New Vacancy") { var data = _NotificationMethod.GetNewVacancyNotificationByKey(EmployeeID, DetailsId).FirstOrDefault(); if (data != null) { _NotificationDetail.EmployeeId = null; _NotificationDetail.HeaderType = "New Vacancy"; _NotificationDetail.Vacancy = data.Title; _NotificationDetail.ClosingDate = data.ClosingDate; _NotificationDetail.RecruitementProcess = data.RecruitmentProcesses; _NotificationDetail.SalaryRange = data.Salary; _NotificationDetail.Location = data.Location; _NotificationDetail.Business = data.Business; _NotificationDetail.Division = data.Division; _NotificationDetail.Pool = data.Pool; _NotificationDetail.Function = data.Functions; Vacancy VacancyDetails = new Vacancy(); VacancyDetails = _db.Vacancies.Find(DetailsId); VacancyDetails.IsRead = true; _db.Entry(VacancyDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } else if (Header == "Uplift Submission") { var data = _NotificationMethod.GetUpLiftNotificationByKey(EmployeeID, DetailsId).FirstOrDefault(); if (data != null) { _NotificationDetail.EmployeeId = data.EmployeeId; _NotificationDetail.HeaderType = data.HeaderType; _NotificationDetail.Day = data.day; _NotificationDetail.Date = data.Date; _NotificationDetail.UpliftPosition = data.UpliftPostionId; _NotificationDetail.Hours = data.Hours; _NotificationDetail.ProjectName = data.Project; _NotificationDetail.CustomerName = data.Customer; _NotificationDetail.ChangeInWorkRate = data.WorkerRate; _NotificationDetail.ChangeInCustomerRate = data.CustomerRate; Employee_ProjectPlanner_Uplift_Detail UpliftDetails = new Employee_ProjectPlanner_Uplift_Detail(); var reportTodata = _db.EmployeeRelations.Where(x => x.IsActive == true && x.UserID == EmployeeID).FirstOrDefault(); UpliftDetails = _db.Employee_ProjectPlanner_Uplift_Detail.Find(DetailsId); var aspnetUserDetails = _db.AspNetUsers.Where(x => x.Id == EmployeeID && x.Archived == false).FirstOrDefault(); if (UpliftDetails != null && UpliftDetails.ApprovalStatus == "Pending") { _NotificationDetail.AppStatus = UpliftDetails.ApprovalStatus; } if (aspnetUserDetails != null && UpliftDetails != null) { if (aspnetUserDetails.HRResponsible == SessionProxy.UserId && aspnetUserDetails.HRResponsible != null) { UpliftDetails.IsReadHR = true; } if (aspnetUserDetails.AdditionalReportsto == SessionProxy.UserId) { UpliftDetails.IsReadAddRep = true; } if (UpliftDetails != null && reportTodata.Reportsto == SessionProxy.UserId) { UpliftDetails.IsRead = true; } _db.Entry(UpliftDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } } else if (Header == "Skill Endorsement") { Employee_AddEndrosementSkills EndrosementSkillseDetails = new Employee_AddEndrosementSkills(); EndrosementSkillseDetails = _db.Employee_AddEndrosementSkills.Find(DetailsId); EndrosementSkillseDetails.IsRead = true; _db.Entry(EndrosementSkillseDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } else if (Header == "New Resource") { var data = _NotificationMethod.getNewResourceDetails(EmployeeID); if (data != null) { _NotificationDetail.EmployeeId = data.Id; _NotificationDetail.HeaderType = "New Resource"; _NotificationDetail.StartDate = Convert.ToString(data.StartDate); _NotificationDetail.email = Convert.ToString(data.UserName); AspNetUser aspDetails = new AspNetUser(); var reportTodata = _db.EmployeeRelations.Where(x => x.IsActive == true && x.UserID == EmployeeID).FirstOrDefault(); aspDetails = _db.AspNetUsers.Find(EmployeeID); if (aspDetails.HRResponsible == SessionProxy.UserId) { aspDetails.IsReadHRRespo = true; } if (aspDetails.AdditionalReportsto == SessionProxy.UserId) { aspDetails.IsReadAddReport = true; } if (reportTodata != null && reportTodata.Reportsto == SessionProxy.UserId) { aspDetails.IsReadNewResource = true; } _db.Entry(aspDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } else if (Header == "Delete employee") { var data = _NotificationMethod.getDeleteResourceDetails(EmployeeID); if (data != null) { _NotificationDetail.EmployeeId = data.Id; _NotificationDetail.HeaderType = "Delete employee"; _NotificationDetail.EmployeeName = data.FirstName + " " + data.LastName; _NotificationDetail.StartDate = Convert.ToString(data.StartDate); _NotificationDetail.email = Convert.ToString(data.UserName); AspNetUser aspDetails = new AspNetUser(); aspDetails = _db.AspNetUsers.Find(EmployeeID); aspDetails.IsReadArchived = true; _db.Entry(aspDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } else if (Header == "New Document") { var data = _NotificationMethod.getEmployeeDocumentByKey(Convert.ToInt32(DetailsId)); _NotificationDetail.EmployeeId = data.Id; _NotificationDetail.HeaderType = "New Document"; _NotificationDetail.DocumentName = data.DocumentPath; _NotificationDetail.Description = data.Description; _NotificationDetail.DocLink = data.LinkURL; Employee_Document aspDetails = new Employee_Document(); aspDetails = _db.Employee_Document.Find(DetailsId); aspDetails.IsRead = true; _db.Entry(aspDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } else if (Header == "Document Signature") { var data = _NotificationMethod.getEmployeeDocumentForSignatureByKey(Convert.ToInt32(DetailsId)); _NotificationDetail.EmployeeId = data.Id; _NotificationDetail.HeaderType = "Document Signature"; _NotificationDetail.DocumentName = data.DocumentPath; _NotificationDetail.Description = data.Description; _NotificationDetail.DocLink = data.LinkURL; Employee_Document aspDetails = new Employee_Document(); aspDetails = _db.Employee_Document.Find(DetailsId); aspDetails.IsReadSignature = true; _db.Entry(aspDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } else if (Header == "New Vacancy Posted") { var data = _NotificationMethod.getVacancyByKey(Convert.ToInt32(DetailsId)); _NotificationDetail.EmployeeId = data.Id; _NotificationDetail.HeaderType = "New Vacancy Posted"; Vacancy vacDetails = new Vacancy(); vacDetails = _db.Vacancies.Find(DetailsId); vacDetails.IsReadVacancy = true; _db.Entry(vacDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } else if (Header == "New Applicant") { var data = _NotificationMethod.getTMSApplicantDetailByKey(Convert.ToInt32(EmployeeID)); _NotificationDetail.EmployeeId = data.Id; _NotificationDetail.HeaderType = "New Applicant"; TMS_Applicant aspDetails = new TMS_Applicant(); aspDetails = _db.TMS_Applicant.Find(EmployeeID); aspDetails.IsReadHiringLead = true; _db.Entry(aspDetails).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } return(PartialView("_GetNotificationDetails", _NotificationDetail)); }