public ActionResult AddNew(Accountability data) { if (ModelState.IsValid) { data.DepartmentID = dbEmployee.GetDepartmentID(User.Identity.Name); dbContext.AddAccountability(data); } return RedirectToAction("Index"); }
public ActionResult Edit(int id, Accountability data) { if (ModelState.IsValid) { data.DepartmentID = dbEmployee.GetDepartmentID(User.Identity.Name); if (data.Status) { dbContext.DisableConfirmationCode(data.StudentNumber); } dbContext.EditAccountability(data, id); } return RedirectToAction("Index"); }
public void EditAccountability(Accountability data, int id) { ExecuteNonQuery(QueryBuilder.Update(_tableName, TargetFields, id, _pkField), SetParams(data)); }
public void AddAccountability(Accountability data) { ExecuteNonQuery(QueryBuilder.Insert(_tableName, TargetFields), SetParams(data)); }
private Dictionary<string, object> SetParams(Accountability data) { Dictionary<string, object> result = new Dictionary<string, object>(); result.Add("@description", data.Description); result.Add("@studentNumber", data.StudentNumber); result.Add("@departmentID", data.DepartmentID); result.Add("@status", data.Status); return result; }
public string MassUpload(HttpPostedFileBase excelFile, int departmentID) { try { foreach (KeyValuePair<string, string> value in ReadExcel(excelFile)) { Accountability accountability = new Accountability { DepartmentID = departmentID, Description = value.Value, StudentNumber = value.Key }; AddAccountability(accountability); } return "Mass upload was successful!"; } catch (Exception ex) { return ex.Message; } }