public ActionResult DeleteFee(long id) { var gVal = new GenericValidator(); try { if (id < 1) { gVal.Code = -1; gVal.Error = "Invalid selection"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var delStatus = new FeeServices().DeleteFee(id); if (delStatus < 1) { gVal.Code = -1; gVal.Error = "Fee could not be deleted. Please try again later."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = 5; gVal.Error = "Fee Information was successfully deleted"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
public ActionResult EditFee(FeeObject fee) { var gVal = new GenericValidator(); try { var stat = ValidateFee(fee); if (stat.Code < 1) { return(Json(gVal, JsonRequestBehavior.AllowGet)); } if (Session["_fee"] == null) { gVal.Code = -1; gVal.Error = "Session has timed out."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var oldfee = Session["_fee"] as FeeObject; if (oldfee == null) { gVal.Code = -1; gVal.Error = "Session has timed out."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } oldfee.ImportStageId = fee.ImportStageId; oldfee.FeeTypeId = fee.FeeTypeId; oldfee.Amount = fee.Amount; oldfee.Name = fee.Name; oldfee.PrincipalSplit = fee.PrincipalSplit; oldfee.VendorSplit = fee.VendorSplit; oldfee.PaymentGatewaySplit = fee.PaymentGatewaySplit; oldfee.BillableToPrincipal = fee.BillableToPrincipal; oldfee.CurrencyCode = fee.CurrencyCode; var docStatus = new FeeServices().UpdateFee(oldfee); if (docStatus < 1) { gVal.Code = -1; gVal.Error = docStatus == -3 ? "Fee already exists." : "Fee information could not be updated. Please try again later"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = oldfee.FeeId; gVal.Error = "Fee information was successfully updated"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { gVal.Code = -1; gVal.Error = "Fee information could not be updated. Please try again later"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
public ActionResult GetFeeObjects(JQueryDataTableParamModel param) { try { IEnumerable <FeeObject> filteredParentMenuObjects; var countG = 0; var pagedParentMenuObjects = GetFees(param.iDisplayLength, param.iDisplayStart, out countG); if (!string.IsNullOrEmpty(param.sSearch)) { filteredParentMenuObjects = new FeeServices().Search(param.sSearch); } else { filteredParentMenuObjects = pagedParentMenuObjects; } if (!filteredParentMenuObjects.Any()) { return(Json(new List <FeeObject>(), JsonRequestBehavior.AllowGet)); } var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]); Func <FeeObject, string> orderingFunction = (c => sortColumnIndex == 1 ? c.FeeTypeName : c.ImportStageName); var sortDirection = Request["sSortDir_0"]; // asc or desc filteredParentMenuObjects = sortDirection == "desc" ? filteredParentMenuObjects.OrderBy(orderingFunction) : filteredParentMenuObjects.OrderByDescending(orderingFunction); var displayedPersonnels = filteredParentMenuObjects; var result = from c in displayedPersonnels select new[] { Convert.ToString(c.FeeId), c.FeeTypeName, c.ImportStageName, c.Amount.ToString("N2") }; return(Json(new { param.sEcho, iTotalRecords = countG, iTotalDisplayRecords = countG, aaData = result }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(Json(new List <FeeObject>(), JsonRequestBehavior.AllowGet)); } }
public ActionResult GetFee(long id) { try { var fee = new FeeServices().GetFee(id); if (fee == null || fee.FeeId < 1) { return(Json(new FeeObject(), JsonRequestBehavior.AllowGet)); } Session["_fee"] = fee; return(Json(fee, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(new FeeObject(), JsonRequestBehavior.AllowGet)); } }
public ActionResult AddFee(FeeObject fee) { var gVal = new GenericValidator(); try { var importerInfo = GetLoggedOnUserInfo(); if (importerInfo.Id < 1) { gVal.Error = "Your session has timed out"; gVal.Code = -1; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var validationResult = ValidateFee(fee); if (validationResult.Code == 1) { return(Json(validationResult, JsonRequestBehavior.AllowGet)); } var appStatus = new FeeServices().AddFee(fee); if (appStatus < 1) { validationResult.Code = -1; validationResult.Error = appStatus == -2 ? "Fee could not be added. Please try again." : "The Fee Information already exists"; return(Json(validationResult, JsonRequestBehavior.AllowGet)); } gVal.Code = appStatus; gVal.Error = "Fee was successfully added."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { gVal.Error = "Fee processing failed. Please try again later"; gVal.Code = -1; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
public GenericValidator PostSplitPaymentForApplicationFee(double amount, string orderId, string payerName, string payerEmail, string payerPhone, string returnUrl, List <FeeObject> fees) { var helper = new SplitPaymentHelper(); var mecharntId = ((long)RemitaServiceType.MecharntId).ToString(); var apiKey = ((long)RemitaServiceType.ApiKey).ToString(); var serviceTypeId = ((long)RemitaServiceType.Application).ToString(); const string url = "https://login.remita.net/remita/ecomm/split/init.reg"; //const string mecharntId = "2547916"; //const string serviceTypeId = "4430731"; //const string apiKey = "1946"; //const string url = "http://www.remitademo.net/remita/ecomm/v2/init.reg"; var hashValue = mecharntId + serviceTypeId + orderId + amount.ToString(CultureInfo.InvariantCulture) + returnUrl + apiKey; var hash = helper.GetHash(hashValue); var items = helper.ComputeApplicationPaymentSplit(amount, fees); var gVal = new GenericValidator(); try { var splitPay = new SplitPayment { MerchantId = mecharntId, ServiceTypeId = serviceTypeId, TotalAmount = amount.ToString(CultureInfo.InvariantCulture), Hash = hash, OrderId = orderId, Responseurl = returnUrl, PayerName = payerName, PayerEmail = payerEmail, PayerPhone = payerPhone, LineItems = items, }; var json = JsonConvert.SerializeObject(splitPay); using (var client = new WebClient()) { try { client.Headers[HttpRequestHeader.Accept] = "application/json"; client.Headers[HttpRequestHeader.ContentType] = "application/json"; var result = client.UploadString(url, "POST", json); //client.UploadString(url, "POST", json); result = result.Replace("jsonp", ""); result = result.Replace("(", ""); result = result.Replace(")", ""); var res = JsonConvert.DeserializeObject <ResponseObject>(result); gVal.Code = 5; gVal.Error = res.RRR; gVal.Hash = hash; var list = new List <PaymentDistributionSummaryObject>(); items.ToList().ForEach(m => { double bAmount; var d = double.TryParse(m.BeneficiaryAmount, out bAmount); if (!d || bAmount < 1) { return; } list.Add(new PaymentDistributionSummaryObject { ServiceId = (int)ServiceDescriptionEnum.Import_Permit_Application_Fee, Beneficiary = m.BeneficiaryName, Amount = bAmount, PaymentReference = res.RRR, PaymentDate = DateTime.Now, Status = false }); }); var logStatus = new FeeServices().LogPaymentDetails(list); if (logStatus < 1) { gVal.Code = -1; gVal.Error = "An unknown error was encountered. Request could not be completed."; return(gVal); } return(gVal); } catch (HttpRequestException e) { gVal.Code = -1; gVal.Error = e.Message; return(gVal); } } } catch (Exception e) { gVal.Code = -1; gVal.Error = e.Message; return(gVal); } }