public long AddBank(BankObject bank) { try { if (bank == null) { return(-2); } if (_repository.Count(m => m.FullName.Trim().ToLower() == bank.FullName.Trim().ToLower()) > 0) { return(-3); } if (_repository.Count(m => m.SortCode.Trim().ToLower() == bank.SortCode.Trim().ToLower()) > 0) { return(-4); } var bankEntity = ModelCrossMapper.Map <BankObject, Bank>(bank); if (bankEntity == null || string.IsNullOrEmpty(bankEntity.FullName)) { return(-2); } var returnStatus = _repository.Add(bankEntity); _uoWork.SaveChanges(); return(returnStatus.BankId); } catch (Exception ex) { ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
public Int32 UpdateBank(BankObject bank) { try { if (bank == null) { return(-2); } if (_repository.Count(m => m.FullName.Trim().ToLower() == bank.FullName.Trim().ToLower() && (m.BankId != bank.BankId)) > 0) { return(-3); } if (_repository.Count(m => m.SortCode.Trim().ToLower() == bank.SortCode.Trim().ToLower() && (m.BankId != bank.BankId)) > 0) { return(-4); } var bankEntity = ModelCrossMapper.Map <BankObject, Bank>(bank); if (bankEntity == null || bankEntity.BankId < 1) { return(-2); } _repository.Update(bankEntity); _uoWork.SaveChanges(); return(5); } catch (Exception ex) { ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message); return(-2); } }
private GenericValidator ValidateBank(BankObject bank) { var gVal = new GenericValidator(); try { if (string.IsNullOrEmpty(bank.Name)) { gVal.Code = -1; gVal.Error = "Please provide Bank Name."; return(gVal); } if (string.IsNullOrEmpty(bank.SortCode)) { gVal.Code = -1; gVal.Error = "Please provide Bank Sort Code."; return(gVal); } gVal.Code = 5; return(gVal); } catch (Exception) { gVal.Code = -1; gVal.Error = "Bank Validation failed. Please provide all required fields and try again."; return(gVal); } }
void OnTriggerEnter2D(Collider2D other) { // Do nothing for background/ground if (other.tag == "Background" || other.tag == "LevelBlock") { // do nothing } // If it is a game object, return it to the bank else if (other.tag == "BankObject") { BankObject obj = other.transform.gameObject.GetComponent <BankObject>(); if (obj != null) { obj.ReturnToBank(); } } else if (other.tag == "LevelBlockEnd") { other.transform.parent.GetComponent <LevelBlock>().SetIsUsed(false); } // Destroy everything else else { Destroy(other.gameObject); } }
public long UpdateBank(BankObject bank) { try { if (bank == null) { return(-2); } var bankEntity = ModelMapper.Map <BankObject, Bank>(bank); if (bankEntity == null || bankEntity.BankId < 1) { return(-2); } using (var db = new ImportPermitEntities()) { if (db.Banks.Count(m => (m.SortCode.ToLower() == bank.SortCode.ToLower() || m.Name.ToLower().Trim() == bank.Name.ToLower().Trim()) && m.BankId != bank.BankId) > 0) { return(-3); } db.Banks.Attach(bankEntity); db.Entry(bankEntity).State = EntityState.Modified; db.SaveChanges(); return(bank.BankId); } } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
public long AddBank(BankObject bank) { try { if (bank == null) { return(-2); } var bankEntity = ModelMapper.Map <BankObject, Bank>(bank); if (bankEntity == null || bankEntity.ImporterId < 1) { return(-2); } using (var db = new ImportPermitEntities()) { if (db.Banks.Count( m => m.SortCode.ToLower() == bank.SortCode.ToLower() || m.ImporterId == bank.ImporterId) > 0) { return(-3); } var returnStatus = db.Banks.Add(bankEntity); db.SaveChanges(); return(returnStatus.BankId); } } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
private GenericValidator ValidateBank(BankObject bank) { var gVal = new GenericValidator(); if (bank == null) { gVal.Code = -1; gVal.Error = message_Feedback.Fatal_Error; return(gVal); } if (string.IsNullOrEmpty(bank.FullName)) { gVal.Code = -1; gVal.Error = message_Feedback.Bank_Name_Error; return(gVal); } if (string.IsNullOrEmpty(bank.SortCode)) { gVal.Code = -1; gVal.Error = message_Feedback.Bank_Sort_Code_Error; return(gVal); } gVal.Code = 5; gVal.Error = ""; return(gVal); }
// ---------------------------------------------------------------------------------------------------------------------- // "Create" the loin // ---------------------------------------------------------------------------------------------------------------------- void CreateLoin(Vector2 position) { BankObject loin = this.GetUnusedLoin(); if (loin != null) { loin.MoveTo(position); } }
public ActionResult AddBank(BankObject bank) { var gVal = new GenericValidator(); try { if (ModelState.IsValid) { var valStatus = ValidateBank(bank); if (valStatus.Code < 1) { gVal.Code = 0; gVal.Error = valStatus.Error; return(Json(gVal, JsonRequestBehavior.AllowGet)); } bank.LastUpdated = DateTime.Now.ToString("yyyy/mm/dd hh:mm:ss tt"); var logoPath = SaveFile(""); if (!string.IsNullOrEmpty(logoPath)) { bank.LogoPath = logoPath; } var k = new BankServices().AddBank(bank); if (k < 1) { if (k == -3) { gVal.Error = message_Feedback.Item_Duplicate; } if (k == -4) { gVal.Error = message_Feedback.Duplicate_Sort_Code; } if (k != -3 && k != -4) { gVal.Error = message_Feedback.Update_Failure; } gVal.Code = 0; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = k; gVal.Error = message_Feedback.Insertion_Success; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = -5; gVal.Error = message_Feedback.Model_State_Error; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch { gVal.Code = 0; gVal.Error = message_Feedback.Process_Failed; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
static void Main(string[] args) { Console.Title = typeof(Program).Namespace; while (true) { string input = RabbitMq.RabbitMq.Output("PBAG3_Recipient"); BankObject bank = JsonConvert.DeserializeObject <BankObject>(input); List <BankObject.Bank> recipientList = new List <BankObject.Bank>(); foreach (var item in bank.Banks) { item.creditScore = bank.CreditScore; item.ssn = bank.Ssn; item.loanAmount = bank.LoanAmount; item.loanDuration = bank.LoanDuration; recipientList.Add(item); } int number = recipientList.Count; string jsonObject; bool success; for (int i = 0; i < number; i++) { switch (recipientList[i].bankId) { case "bankRest": jsonObject = JsonConvert.SerializeObject(recipientList[i]); success = RabbitMq.RabbitMq.Input("PBAG3_Translator_RestBank", jsonObject); break; case "bankJson": jsonObject = JsonConvert.SerializeObject(recipientList[i]); success = RabbitMq.RabbitMq.Input("PBAG3_Translator_JsonBank", jsonObject); break; case "bankXml": jsonObject = JsonConvert.SerializeObject(recipientList[i]); success = RabbitMq.RabbitMq.Input("PBAG3_Translator_XmlBank", jsonObject); break; case "bankRabbit": jsonObject = JsonConvert.SerializeObject(recipientList[i]); success = RabbitMq.RabbitMq.Input("PBAG3_Translator_RabbitBank", jsonObject); break; default: Console.WriteLine("Error! No Bank existed"); break; } } } }
public long AddBank(BankObject bank) { try { return(_bankManager.AddBank(bank)); } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
public int UpdateBank(BankObject bankAccount) { try { return(_bankAccountRepository.UpdateBank(bankAccount)); } catch (Exception ex) { ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message); return(-2); } }
public ActionResult AddBank(BankObject bank) { var gVal = new GenericValidator(); try { var validationResult = ValidateBank(bank); if (validationResult.Code == 1) { return(Json(validationResult, JsonRequestBehavior.AllowGet)); } var company = new ImporterObject { Id = 0, Name = bank.Name, TIN = bank.TIN, RCNumber = bank.RCNumber, IsActive = true, DateAdded = DateTime.Now.ToString("dd/MM/yyyy") }; var cmStatus = AddCompany(company); if (cmStatus.Code < 1) { return(Json(cmStatus, JsonRequestBehavior.AllowGet)); } bank.ImporterId = cmStatus.Code; var appStatus = new BankServices().AddBank(bank); if (appStatus < 1) { validationResult.Code = -1; validationResult.Error = appStatus == -2 ? "Bank processing failed. Please try again." : "Bank Information already exists"; return(Json(validationResult, JsonRequestBehavior.AllowGet)); } gVal.Code = appStatus; gVal.Error = "Bank was successfully added."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { gVal.Error = "Bank processing failed. Please try again later"; gVal.Code = -1; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
// ---------------------------------------------------------------------------------------------------------------------- // Get an unused loin, if not return a random first one // ---------------------------------------------------------------------------------------------------------------------- BankObject GetUnusedLoin() { BankObject rand = bank[1]; // bank[1]; for (int i = 0; i < bank.Count; i++) { if (!bank[i].isInUse) { return(bank[i]); } } if (rand.isInUse) { rand = null; } return(rand); // this shouldn't happen }
void Awake() { // Register the singleton if (Instance != null) { Debug.LogError("Multiple instances of Loin Spawner"); } Instance = this; // Get loins bank = new List <BankObject>(); for (int i = 0; i < transform.childCount; i++) { Transform child = transform.GetChild(i); if (child != null) { BankObject tempObj = child.GetComponent <BankObject>(); bank.Add(tempObj); } } }
public List <BankObject> GetBanks(int?itemsPerPage, int?pageNumber, out int countG) { try { if ((itemsPerPage != null && itemsPerPage > 0) && (pageNumber != null && pageNumber >= 0)) { var tpageNumber = (int)pageNumber; var tsize = (int)itemsPerPage; using (var db = new ImportPermitEntities()) { var banks = db.Banks.OrderByDescending(m => m.BankId).Include("Importer").Skip(tpageNumber).Take(tsize).ToList(); if (!banks.Any()) { countG = 0; return(new List <BankObject>()); } var newList = new List <BankObject>(); banks.ForEach(h => { var bnk = new BankObject { BankId = h.BankId, ImporterId = h.ImporterId, SortCode = h.SortCode, Name = h.Name, NotificationEmail = h.NotificationEmail }; var usrs = (from pp in db.People.Where(n => n.ImporterId == h.ImporterId) join tt in db.UserProfiles.Include("AspNetUsers") on pp.Id equals tt.PersonId where tt.IsAdmin select new { tt, pp }).ToList(); if (usrs.Any()) { var usr = usrs[0].tt; var p = usrs[0].pp; if (usr != null && usr.Id > 0 && p.Id > 0) { bnk.UserId = usr.AspNetUsers.ElementAt(0).Id; bnk.LastName = p.FirstName + " " + p.LastName; bnk.PhoneNumber = usr.AspNetUsers.ElementAt(0).PhoneNumber; } } else { bnk.UserId = ""; bnk.PhoneNumber = ""; bnk.LastName = ""; } newList.Add(bnk); }); countG = db.Banks.Count(); return(newList); } } countG = 0; return(new List <BankObject>()); } catch (Exception ex) { countG = 0; return(new List <BankObject>()); } }
public ActionResult EditBank(BankObject bank) { var gVal = new GenericValidator(); try { var stat = ValidateBank(bank); if (stat.Code < 1) { return(Json(gVal, JsonRequestBehavior.AllowGet)); } if (Session["_bank"] == null) { gVal.Code = -1; gVal.Error = "Session has timed out."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var oldbank = Session["_bank"] as BankObject; if (oldbank == null) { gVal.Code = -1; gVal.Error = "Session has timed out."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var company = new ImporterObject { Id = oldbank.ImporterId, Name = bank.Name, TIN = bank.TIN, RCNumber = bank.RCNumber }; var cmStatus = EditCompany(company); if (cmStatus.Code < 1) { return(Json(cmStatus, JsonRequestBehavior.AllowGet)); } oldbank.Name = bank.Name; oldbank.NotificationEmail = bank.NotificationEmail; oldbank.SortCode = bank.SortCode; var docStatus = new BankServices().UpdateBank(oldbank); if (docStatus < 1) { gVal.Code = -1; gVal.Error = docStatus == -3 ? "Bank already exists." : "Bank information could not be updated. Please try again later"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = oldbank.BankId; gVal.Error = "Bank information was successfully updated"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { gVal.Code = -1; gVal.Error = "Bank information could not be updated. Please try again later"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
public ActionResult EditBank(BankObject bank) { var gVal = new GenericValidator(); try { if (ModelState.IsValid) { var valStatus = ValidateBank(bank); if (valStatus.Code < 1) { gVal.Code = 0; gVal.Error = valStatus.Error; return(Json(gVal, JsonRequestBehavior.AllowGet)); } if (Session["_bank"] == null) { gVal.Code = -1; gVal.Error = message_Feedback.Session_Time_Out; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var oldBank = Session["_bank"] as BankObject; if (oldBank == null || oldBank.BankId < 1) { gVal.Code = -1; gVal.Error = message_Feedback.Session_Time_Out; return(Json(bank, JsonRequestBehavior.AllowGet)); } oldBank.FullName = bank.FullName.Trim(); oldBank.ShortName = bank.ShortName.Trim(); oldBank.SortCode = bank.SortCode.Trim(); var formerLogoPath = string.Empty; if (!string.IsNullOrEmpty(oldBank.LogoPath)) { formerLogoPath = oldBank.LogoPath; } var logoPath = SaveFile(formerLogoPath); if (!string.IsNullOrEmpty(logoPath)) { oldBank.LogoPath = logoPath; } var k = new BankServices().UpdateBank(oldBank); if (k < 1) { if (k == -3) { gVal.Error = message_Feedback.Item_Duplicate; } if (k == -4) { gVal.Error = message_Feedback.Duplicate_Sort_Code; } if (k != -3 && k != -4) { gVal.Error = message_Feedback.Update_Failure; } gVal.Error = message_Feedback.Update_Success; gVal.Code = 0; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Error = message_Feedback.Insertion_Success; gVal.Code = 5; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = -5; gVal.Error = message_Feedback.Model_State_Error; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch { gVal.Code = 0; gVal.Error = message_Feedback.Process_Failed; return(Json(bank, JsonRequestBehavior.AllowGet)); } }