public ActionResult AddIncrementDetails(Employee_SalaryIncrement Inc) { string status = "error"; if (Inc.AfterSalary > 0) { Employee_SalaryRecord es = db.Employee_SalaryRecord.Where(x => x.EmployeeId == Inc.EmpSalaryRecordId).FirstOrDefault(); es.CurrentSalary = Inc.AfterSalary; es.TimeStamp = DateTime.Now; if (db.SaveChanges() > 0) { Employee_SalaryIncrement Inc_Rec = new Employee_SalaryIncrement(); Inc_Rec.IncrementAmount = Inc.IncrementAmount; Inc_Rec.PreviousSalary = Inc.PreviousSalary; Inc_Rec.EmpSalaryRecordId = es.Id; Inc_Rec.AfterSalary = Inc.AfterSalary; Inc_Rec.TimeStamp = DateTime.Now; db.Employee_SalaryIncrement.Add(Inc_Rec); if (db.SaveChanges() > 0) { status = "success"; } } } return(Content(status)); }
public ActionResult AddRecord(Employee_SalaryRecord Record) { string Status = "error"; try { if (db.Employee_SalaryRecord.Where(x => x.EmployeeId == Record.EmployeeId).Count() > 0) { Status = "AlreadyExists"; } else { Record.CurrentSalary = Record.StartingSalary; Record.TimeStamp = DateTime.Now; db.Employee_SalaryRecord.Add(Record); if (db.SaveChanges() > 0) { Status = "success"; } } } catch (Exception) { Status = "error"; } return(Content(Status)); }
public ActionResult Edit([Bind(Include = "EmployeeId,CurrentSalary,TimeStamp")] Employee_SalaryRecord employee_salary) { if (ModelState.IsValid) { Employee_SalaryRecord record = db.Employee_SalaryRecord.Where(x => x.EmployeeId == employee_salary.EmployeeId).FirstOrDefault(); record.StartingSalary = employee_salary.CurrentSalary; record.TimeStamp = DateTime.Now; record.CurrentSalary = employee_salary.CurrentSalary; db.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Employee_SalaryRecord employee_salary = db.Employee_SalaryRecord.Where(x => x.EmployeeId == id).FirstOrDefault(); if (employee_salary == null) { return(HttpNotFound()); } ViewBag.EmployeeId = new SelectList(db.AspNetEmployees.Where(x => x.AspNetUser.Status != "False"), "Id", "Name"); return(View(employee_salary)); }