public ActionResult Approval(ExpenseApprovalModel expenseapprovalmodel) { try { if (expenseapprovalmodel.Comment == null) { return(Json(false)); } if (string.IsNullOrEmpty(Convert.ToString(expenseapprovalmodel.ExpenseID))) { return(Json(false)); } _IExpense.UpdateExpenseStatus(expenseapprovalmodel, 2); //Approve if (_IExpense.IsExpenseALreadyProcessed(expenseapprovalmodel.ExpenseID)) { _IExpense.UpdateExpenseAuditStatus(expenseapprovalmodel.ExpenseID, expenseapprovalmodel.Comment, 2); } else { _IExpense.InsertExpenseAuditLog(InsertExpenseAudit(expenseapprovalmodel, 2)); } return(Json(true)); } catch (Exception) { throw; } }
public bool UpdateExpenseStatus(ExpenseApprovalModel ExpenseApprovalModel, int ExpenseStatus) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TimesheetDBEntities"].ToString())) { con.Open(); SqlTransaction sql = con.BeginTransaction(); try { var param = new DynamicParameters(); param.Add("@ExpenseID", ExpenseApprovalModel.ExpenseID); param.Add("@Comment", ExpenseApprovalModel.Comment); param.Add("@ExpenseStatus", ExpenseStatus); var result = con.Execute("Usp_UpdateExpenseStatus", param, sql, 0, System.Data.CommandType.StoredProcedure); if (result > 0) { sql.Commit(); return(true); } else { sql.Rollback(); return(false); } } catch (Exception) { sql.Rollback(); throw; } } }
public bool UpdateExpenseStatus(ExpenseApprovalModel ExpenseApprovalModel, int ExpenseStatus) { try { using (var _context = new DatabaseContext()) { var expenseModel = _context.ExpenseModel.FirstOrDefault(c => c.ExpenseID == ExpenseApprovalModel.ExpenseID); expenseModel.Comment = ExpenseApprovalModel.Comment; expenseModel.ExpenseStatus = ExpenseStatus; _context.Entry(expenseModel).State = EntityState.Modified; var result = _context.SaveChanges(); if (result > 0) { return(true); } else { return(false); } } } catch (Exception) { throw; } }
private ExpenseAuditTB InsertExpenseAudit(ExpenseApprovalModel TimeSheetApproval, int Status) { try { ExpenseAuditTB objAuditTB = new ExpenseAuditTB(); objAuditTB.ApprovaExpenselLogID = 0; objAuditTB.ExpenseID = TimeSheetApproval.ExpenseID; objAuditTB.Status = Status; objAuditTB.CreatedOn = DateTime.Now; objAuditTB.Comment = TimeSheetApproval.Comment; objAuditTB.ApprovalUser = Convert.ToInt32(Session["AdminUser"]); objAuditTB.ProcessedDate = DateTime.Now; objAuditTB.UserID = _IUsers.GetUserIDbyExpenseID(TimeSheetApproval.ExpenseID); return(objAuditTB); } catch (Exception) { throw; } }