コード例 #1
0
ファイル: BankAccountBL.cs プロジェクト: RomyPutra/BillBackup
        public AddBankAccountResponseMoodel Save(AddBankAccountInputModel data)
        {
            UserBank temp = new UserBank();

            temp.AccountName    = data.AccountName;
            temp.AccountNumber  = data.AccountNumber;
            temp.BankID         = data.BankID;
            temp.ID             = Guid.NewGuid();
            temp.isSelected     = data.isSelected;
            temp.UserID         = data.UserID;
            temp.CreateByUserID = data.UserID;
            temp.CreateDate     = DateTime.Now;

            UserBankRepository repo = new UserBankRepository(db);

            var res = repo.Insert(temp);

            AddBankAccountOutputModel output = new AddBankAccountOutputModel();

            output.BankID = data.BankID;
            output.UserID = data.UserID;

            AddBankAccountResponseMoodel response = new AddBankAccountResponseMoodel();

            response.data     = output;
            response.Message  = res.Message;
            response.Response = res.Result;

            return(response);
        }
コード例 #2
0
        public ActionResult AddBankAccount(AddBankAccountInputModel data)
        {
            string userID = HttpContext.Session.GetString(SessionKeyID);
            AddBankAccountInputModel dataBankAccount = new AddBankAccountInputModel();

            dataBankAccount.AccountNumber = data.AccountNumber;
            dataBankAccount.AccountName   = data.AccountName;
            dataBankAccount.BankID        = data.BankID;
            dataBankAccount.isSelected    = true;
            dataBankAccount.UserID        = Guid.Parse(userID);
            JsonConvert.SerializeObject(dataBankAccount);
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(BaseAPI + "Profile/");
                //HTTP POST
                var postTask = client.PostAsJsonAsync <AddBankAccountInputModel>("AddBankAccount", dataBankAccount);
                postTask.Wait();

                var result = postTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Index", "BankAccount"));
                }
                else
                {
                    TempData["CustomError"] = "Fail to add bank account. Please contact administrator.";
                }
            }
            TempData["CustomError"] = "Terjadi kesalahan. Mohon hubungi admin.";
            return(RedirectToAction("Create", "BankAccount"));
        }
コード例 #3
0
        public ActionResult <AddBankAccountResponseMoodel> AddBankAccount([FromBody] AddBankAccountInputModel data)
        {
            BankAccountBL bl = new BankAccountBL(DbContext);

            return(bl.Save(data));
        }