public async Task <IActionResult> Index(Common.Transaction transaction) { try { if (!(transaction.TrasactionID.ToInt32() > 0 || (transaction.VehicleID.ToInt32() > 0 && transaction.RouteID.ToInt32() > 0))) { ViewBag.Message = "Vehicle No And Route or Trip No is required to save trip information."; ViewBag.MessageType = "error"; } transaction.CreatedBy = UserContext.UserID; var dt = await bALTransaction.SaveTripInfoAsync(transaction); if (dt != null && dt.Rows.Count > 0) { ModelState.Clear(); ViewBag.Message = dt.Rows[0]["Message"].ToText() + (dt.Rows[0]["MessageType"].ToText() == "success" ? $" Route Name: { dt.Rows[0]["RouteName"].ToText() } Check Point Name: { dt.Rows[0]["CheckPointName"].ToText() } Arrived Time: { dt.Rows[0]["ArrivalTime"].ToText() } " : ""); ViewBag.MessageType = dt.Rows[0]["MessageType"].ToText(); } else { ViewBag.Message = "Error while saving trip info. Please contact sytem administrator."; ViewBag.MessageType = "error"; } } catch { ViewBag.Message = "Error while saving trip info. Please contact sytem administrator."; ViewBag.MessageType = "error"; } await LoadVehicleNoAsync(); await LoadRoutesAsync(); return(View()); }
public async Task <IActionResult> DeleteTrip(Common.Transaction transaction) { dynamic model; try { transaction.CreatedBy = UserContext.UserID; await bALTransaction.DeleteTripAsync(transaction); model = new { MessageType = "success", Message = "Trip Information Deleted Successfully." }; } catch { model = new { MessageType = "error", Message = "Error while deleting trip info. Please contact sytem administrator." }; } return(Json(model)); }
public static Guid Decrease(Guid userGuid, decimal amount, TypeCreditChanges typeCreditChanges, string description, Guid referenceGuid, DataAccessBase dataAccessProvider) { try { Business.Transaction transactionController = new Business.Transaction(dataAccessProvider); Business.User userController = new Business.User(dataAccessProvider); decimal currentCredit = userController.GetUserCredit(userGuid); if (currentCredit < amount) { throw new Exception(Language.GetString("ErrorCredit")); } Common.Transaction transaction = new Common.Transaction(); transaction.TypeTransaction = (int)Business.TypeTransactions.Decrease; transaction.ReferenceGuid = referenceGuid; transaction.TypeCreditChange = (int)typeCreditChanges; transaction.Description = description; transaction.CreateDate = DateTime.Now; transaction.CurrentCredit = currentCredit; transaction.Amount = amount; transaction.UserGuid = userGuid; Guid transactionGuid = transactionController.Insert(transaction); if (transactionGuid == Guid.Empty) { throw new Exception(Language.GetString("ErrorRecord")); } if (!userController.UpdateCredit(userGuid, transaction.CurrentCredit - amount)) { throw new Exception(Language.GetString("ErrorRecord")); } return(transactionGuid); } catch (Exception ex) { throw ex; } }
public static Guid Increase(Guid userGuid, decimal amount, TypeCreditChanges typeCreditChanges, string description, Guid referenceGuid, bool updateGrupPrice, DataAccessBase dataAccessProvider) { Business.Transaction transactionController = new Business.Transaction(dataAccessProvider); Business.User userController = new Business.User(dataAccessProvider); Common.Transaction transaction = new Common.Transaction(); decimal currentCredit = userController.GetUserCredit(userGuid); transaction.ReferenceGuid = referenceGuid; transaction.TypeTransaction = (int)Business.TypeTransactions.Increase; transaction.TypeCreditChange = (int)typeCreditChanges; transaction.Description = description; transaction.CreateDate = DateTime.Now; transaction.CurrentCredit = currentCredit; transaction.Amount = amount; transaction.UserGuid = userGuid; Guid transactionGuid = transactionController.Insert(transaction); if (transactionGuid == Guid.Empty) { throw new Exception(Language.GetString("ErrorRecord")); } if (updateGrupPrice) { if (!userController.UpdateCreditAndGroupPrice(userGuid, transaction.CurrentCredit + amount, amount)) { throw new Exception(Language.GetString("ErrorRecord")); } } else { if (!userController.UpdateCredit(userGuid, transaction.CurrentCredit + amount)) { throw new Exception(Language.GetString("ErrorRecord")); } } return(transactionGuid); }