public bool UpdateCardCharges(tbl_Card_Charges row) { try { using (var db = new SoneriCISEntities()) { tbl_Card_Charges val = new DAL.tbl_Card_Charges(); val = db.tbl_Card_Charges.Where(a => a.ID == row.ID).FirstOrDefault(); if (db.tbl_Card_Charges.Any(e => e.Title.ToLower() != val.Title.ToLower() && e.Title.ToLower() == row.Title.ToLower())) { throw new CustomException("Title already exists!"); } val.Title = row.Title; val.Amount = row.Amount; val.AuthorizationComments = row.AuthorizationComments; val.AuthorizationStatus = row.AuthorizationStatus; val.CardTypeID = row.CardTypeID; val.IsActive = row.IsActive; val.IsFED = row.IsFED; val.IsReplacement = row.IsReplacement; db.SaveChanges(); } return(true); } catch (Exception ex) { return(false); } }
public bool AddCardChargesWithRegionalCharges(tbl_Card_Charges CardCharges, tbl_Regional_Charges RegionalCharges) { try { using (var db = new SoneriCISEntities()) { db.tbl_Card_Charges.Add(CardCharges); db.SaveChanges(); RegionalCharges.CardChargeID = CardCharges.ID; AddRegionalCharges(RegionalCharges); } return(true); } catch (Exception ex) { return(false); } }
public ActionResult AddUpdateCardCharges(tbl_Card_Charges request, List <tbl_Regional_Charges> regionRequest = default(List <tbl_Regional_Charges>), int?RequestId = null) { //existing account type modification requests to be handled through System Request Section if (RequestId.HasValue) { var getSystemRequest = new SystemRequestDataAccess().GetSystemRequest(RequestId.GetValueOrDefault(), "R"); var CardChargesDetails = CardChargesMethod.GetCardChargeDetail(request.ID); var existingJson = CardChargesDetails == null ? null : CustomHelper.GetJson(CardChargesDetails); var updatedJson = CustomHelper.GetJson(request); tbl_System_Requests row = new tbl_System_Requests(); if (RequestId.GetValueOrDefault() <= 0) { row = new tbl_System_Requests { AuthorizationStatus = "P", CreatorID = StateHelper.UserId, IsActive = true, ExistingData = existingJson, UpdatedData = updatedJson, RequestType = Constants.RequestTypes.CardCharges_SystemRequest }; } else { row = getSystemRequest; row.CreatorID = StateHelper.UserId; row.AuthorizationStatus = "P"; row.AuthorizationComments = string.Empty; row.UpdatedData = updatedJson; row.ExistingData = existingJson; } var SystemRequestFlag = (RequestId.HasValue && RequestId.GetValueOrDefault() <= 0) ? new SystemRequestDataAccess().AddSystemRequest(row) : new SystemRequestDataAccess().UpdateSystemRequest(row); return(Json(new { IsSuccess = SystemRequestFlag, ErrorMessage = SystemRequestFlag == true ? string.Empty : CustomMessages.GenericErrorMessage, Response = SystemRequestFlag }, JsonRequestBehavior.AllowGet)); } else { request.IsActive = true; var response = request.ID <= 0 ? new CardChargesDataAccess().AddCardCharges(request) : new CardChargesDataAccess().UpdateCardCharges(request); return(Json(new { IsSuccess = response, ErrorMessage = response == true ? string.Empty : CustomMessages.GenericErrorMessage, Response = response }, JsonRequestBehavior.AllowGet)); } }
public bool AddCardCharges(tbl_Card_Charges row) { try { using (var db = new SoneriCISEntities()) { if (db.tbl_Card_Charges.Any(e => e.Title.ToLower() == row.Title.ToLower())) { throw new CustomException("Title already exists!"); } db.tbl_Card_Charges.Add(row); db.SaveChanges(); } return(true); } catch (Exception ex) { return(false); } }