Example #1
0
        public BankViewModel AddBank(BankViewModel model)
        {
            try
            {
                model.IsValid = model.Validate();
                if (model.IsValid)
                {
                    //if (_bdmSvc.CityCodeExists(AppConstants.SITE_CODE, model.City.CityCode))
                    //{
                    //    model.FieldId = "cityCode";
                    //    model.Message = string.Format(AppConstants.VALIDATION_ALREADY_EXISTS, "City Code");
                    //    model.IsValid = false;
                    //}

                    //if (model.IsValid)
                    //{
                    model.Bank.SiteCode = AppConstants.SITE_CODE;
                    //model.Bank.EntityTypeCode = EntityTypeCodes.GFT.ToString();
                    _bdmSvc.AddBank(model.Bank);

                    model.FieldId = "vchNo";
                    model.Bank = new BankBE();
                    model.Banks = _bdmSvc.GetAllBanks(AppConstants.SITE_CODE).Where(m => m.IsActive = true).ToList(); //.GetViewOfAllBanks(AppConstants.SITE_CODE);
                    model.Message = string.Format(AppConstants.CRUD_CREATE, "Bank");
                    //}
                }
            }
            catch (Exception ex)
            {
                model.IsValid = false;
                model.Message = ex.Message;
            }

            return model;
        }
Example #2
0
        public BankViewModel ModifyBank(BankBE mod)
        {
            BankViewModel model = new BankViewModel();

            try
            {
                DBOperations op = mod.IsActive ? DBOperations.Update : DBOperations.Delete;
                mod.SiteCode = AppConstants.SITE_CODE;
                model.Bank = mod;
                model.IsValid = model.Validate();
                if (op == DBOperations.Delete || model.IsValid)
                {
                    //_bdmSvc.ModifyEntity(mod);
                    _bdmSvc.ModifyBank(mod);

                    model.FieldId = "BankName";
                    model.Bank = new BankBE();
                    model.Banks = _bdmSvc.GetAllBanks(AppConstants.SITE_CODE).Where(m => m.IsActive = true).ToList();
                    model.Message = op == DBOperations.Update ? string.Format(AppConstants.CRUD_UPDATE, "Bank Name") : string.Format(AppConstants.CRUD_DELETE, "Bank Name");
                }
            }
            catch (Exception ex)
            {
                model.IsValid = false;
                model.Message = ex.Message;
                if (ex.Message.Contains("Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=472540 for information on understanding and handling optimistic concurrency exceptions."))
                    model.Message = "Unable to modify Region Code";
            }
            return model;
        }