private bool GuiRutTien(ThemGuiRutTienRequest request, ChiTietSoTietKiem chitietSoTruoc, LoaiTietKiem loaitietkiem, LoaiTietKiem khongkyhan, string nghiepvu, SoTk soTietKiem)
        {
            var phieuGuiTien = this.TaoPhieuGuiRut(request);

            if (phieuGuiTien == null)
            {
                return(false);
            }

            var result = this.AddChiTietSo(phieuGuiTien, chitietSoTruoc, loaitietkiem, khongkyhan, nghiepvu, soTietKiem);

            return(result);
        }
 public async Task <bool> ThemGuiRut(ThemGuiRutTienRequest request, SoTk soTietKiem, LoaiTietKiem loaiTietKiem, LoaiTietKiem khongKyHan, ChiTietSoTietKiem chitietSoTruoc)
 {
     if (request.Action == "GUI")
     {
         return(this.GuiRutTien(request, chitietSoTruoc, loaiTietKiem, khongKyHan, "GUI", soTietKiem));
     }
     else if (request.Action == "RUT")
     {
         request.Action = double.Parse(request.SoTien.ToString()) == soTietKiem.SoDu ? "DONG" : "RUT";
         request.SoTien = request.SoTien * -1;
         return(this.GuiRutTien(request, chitietSoTruoc, loaiTietKiem, khongKyHan, request.Action, soTietKiem));
     }
     else
     {
         return(false);
     }
 }
        private PhieuGuiRutTien TaoPhieuGuiRut(ThemGuiRutTienRequest request)
        {
            var phieuGuiRut = new PhieuGuiRutTien
            {
                Mskh      = request.MSKH,
                KhachHang = request.KhachHang,
                SoTien    = Convert.ToDouble(request.SoTien.ToString()),
                Ngay      = request.Ngay
            };

            context.PhieuGuiRutTien.Add(phieuGuiRut);
            if (context.SaveChanges() > 0)
            {
                return(phieuGuiRut);
            }
            else
            {
                return(null);
            }
        }