public IHttpActionResult PutEmployeeRating(int id, EmployeeRating employeeRating) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != employeeRating.EmployeeRatingsID) { return(BadRequest()); } db.Entry(employeeRating).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EmployeeRatingExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task RecalculateRatingsAndCountsAsync(Operation action, Review review, double reviewAverageRating) { var recalculateTasks = new List <Task>(); // recalculate customer ratings and counts if (review.ConsumerRating.HasValue) { CustomerRating ??= new Ratings(); recalculateTasks.Add(Task.Run(() => CustomerRating.RecalculateRatingValues(action, review.ConsumerRating.Value, review.Weight))); } // recalculate employee ratings and counts if (review.EmployeeRating.HasValue) { EmployeeRating ??= new Ratings(); recalculateTasks.Add(Task.Run(() => EmployeeRating.RecalculateRatingValues(action, review.EmployeeRating.Value, review.Weight))); } // recalculate society ratings and counts if (review.SocietyRating.HasValue) { SocietyRating ??= new Ratings(); recalculateTasks.Add(Task.Run(() => SocietyRating.RecalculateRatingValues(action, review.SocietyRating.Value, review.Weight))); } // recalculate average ratings and counts AverageRating ??= new Ratings(); recalculateTasks.Add(Task.Run(() => AverageRating.RecalculateRatingValues(action, reviewAverageRating, review.Weight))); await Task.WhenAll(recalculateTasks).ConfigureAwait(false); }
public ActionResult DeleteConfirmed(int id) { fillUserData(); EmployeeRating employeerating = db.EmployeeRatings.Find(id); db.EmployeeRatings.Remove(employeerating); db.SaveChanges(); return(RedirectToAction("EmployeeRating", new { Employeeid = employeerating.EmployeeId })); }
public void CreateEmployeeRating(int employeeId, int rating) { var employeeRating = new EmployeeRating { EmployeeId = employeeId, Rating = rating }; _db.Add(employeeRating); SaveChanges(); }
public IHttpActionResult GetEmployeeRating(int id) { EmployeeRating employeeRating = db.EmployeeRatings.Find(id); if (employeeRating == null) { return(NotFound()); } return(Ok(employeeRating)); }
public IHttpActionResult PostEmployeeRating(EmployeeRating employeeRating) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.EmployeeRatings.Add(employeeRating); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = employeeRating.EmployeeRatingsID }, employeeRating)); }
public IHttpActionResult DeleteEmployeeRating(int id) { EmployeeRating employeeRating = db.EmployeeRatings.Find(id); if (employeeRating == null) { return(NotFound()); } db.EmployeeRatings.Remove(employeeRating); db.SaveChanges(); return(Ok(employeeRating)); }
// GET: /EmployeeRating/Details/5 public ActionResult Details(int?id) { fillUserData(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EmployeeRating employeerating = db.EmployeeRatings.Find(id); if (employeerating == null) { return(HttpNotFound()); } return(View(employeerating)); }
public ActionResult Edit([Bind(Include = "id,Year,Rating,Status")] EmployeeRating employeerating) { fillUserData(); if (ModelState.IsValid) { EmployeeRating oldRating = db.EmployeeRatings.Find(employeerating.id); oldRating.Year = employeerating.Year; oldRating.Rating = employeerating.Rating; oldRating.Status = employeerating.Status; oldRating.LastModificationDate = DateTime.Now; db.Entry(oldRating).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("EmployeeRating", new { Employeeid = oldRating.EmployeeId })); } return(View(employeerating)); }
public ActionResult Create([Bind(Include = "id,Year,Rating,Status,EmployeeId")] EmployeeRating employeerating) { fillUserData(); if (ModelState.IsValid) { employeerating.CreationDate = DateTime.Now; employeerating.LastModificationDate = DateTime.Now; var map = new Dictionary <string, Double>(); map.Add("A", 50000); map.Add("B", 40000); map.Add("C", 30000); map.Add("D", 20000); map.Add("E", 10000); map.Add("F", 5000); //Update employee Salary with the rating if (employeerating.Status.Equals("Confirmed")) { Employees employee = db.Employees.Find(employeerating.EmployeeId); employeerating.SalaryBeforeUpdate = employee.TotalSalary; employee.TotalSalary += map[employeerating.Rating]; employee.lastModificationDate = DateTime.Now; db.Entry(employee).State = EntityState.Modified; db.SaveChanges(); employeerating.SalaryAfterUpdate = employee.TotalSalary; } else { Employees employee = db.Employees.Find(employeerating.EmployeeId); employeerating.SalaryBeforeUpdate = employee.TotalSalary; employeerating.SalaryAfterUpdate = employee.TotalSalary; } db.EmployeeRatings.Add(employeerating); db.SaveChanges(); return(RedirectToAction("EmployeeRating", new { Employeeid = employeerating.EmployeeId })); } return(View(employeerating)); }
// Update public void UpdateEmployeeRating(EmployeeRating employeeRating) { _db.EmployeeRating.Update(employeeRating); SaveChanges(); }
// CRUD operation for Employee Rating // Create public void CreateEmployeeRating(EmployeeRating employeeRating) { _db.Add(employeeRating); SaveChanges(); }