예제 #1
0
        private void bt_them_Click(object sender, EventArgs e)
        {
            string  ten    = "";
            string  diachi = "";
            decimal mucno  = 0;

            ten    = tb_ten.Text.Trim();
            diachi = tb_diachi.Text.Trim();
            try
            {
                mucno = Convert.ToDecimal(tb_mucno.Text.Trim());
            }
            catch (Exception ex)
            {
                MessageBox.Show("Mức nợ phải nhấp số");
            }

            daily dl = new daily();

            dl.name    = ten;
            dl.address = diachi;
            dl.mucno   = mucno;
            bool rs = DailyService.Insert(dl);

            if (rs)
            {
                MessageBox.Show("Thành công");
                dailyForm.loadFormSach(dataGridView1);
            }
            else
            {
                MessageBox.Show("Thất bại");
            }
        }
예제 #2
0
        private void dataGridView1_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            string i   = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
            int    id  = Convert.ToInt16(i);
            var    res = DailyService.GetBookById(id);

            tb_ma.Text     = res.id.ToString();
            tb_ten.Text    = res.name;
            tb_diachi.Text = res.address;
            tb_mucno.Text  = res.mucno.ToString();
        }
예제 #3
0
        public async Task GetOrCreateDailyTest()
        {
            await using var unit = NewContext();
            var userService        = new UserService(unit, null);
            var transactionService = new TransactionService(userService);
            var dailyService       = new DailyService(unit, userService, transactionService);

            var daily = await dailyService.GetOrCreateDailyAsync(2L);

            Assert.NotNull(daily);
        }
예제 #4
0
        public async Task DailyStreakResetTest()
        {
            await using var unit = NewContext();
            var userService        = new UserService(unit, null);
            var transactionService = new TransactionService(userService);
            var dailyService       = new DailyService(unit, userService, transactionService);

            await dailyService.ClaimDailyAsync(4L);

            var daily = await dailyService.GetOrCreateDailyAsync(4L);

            Assert.Equal(0, daily.CurrentStreak);
        }
예제 #5
0
        public async Task ClaimDailyTest()
        {
            await using var unit = NewContext();
            var userService        = new UserService(unit, null);
            var transactionService = new TransactionService(userService);
            var dailyService       = new DailyService(unit, userService, transactionService);

            var response = await dailyService.ClaimDailyAsync(2L);

            Assert.NotNull(response);
            Assert.Equal(1, response.CurrentStreak);
            Assert.Equal(1, response.LongestStreak);
            Assert.Equal(120, response.AmountClaimed);
            Assert.InRange(
                response.LastClaimTime, DateTime.UtcNow.AddMinutes(-2), DateTime.UtcNow.AddMinutes(2));
        }
예제 #6
0
        public async Task CheckIfDailyUpdatedInDatabaseTest()
        {
            await using var unit = NewContext();
            var userService        = new UserService(unit, null);
            var transactionService = new TransactionService(userService);
            var dailyService       = new DailyService(unit, userService, transactionService);

            await dailyService.ClaimDailyAsync(2L);

            var daily = await dailyService.GetOrCreateDailyAsync(2L);

            Assert.NotNull(daily);
            Assert.Equal(1, daily.CurrentStreak);
            Assert.Equal(1, daily.LongestStreak);
            Assert.InRange(daily.LastClaimTime, DateTime.UtcNow.AddMinutes(-2), DateTime.UtcNow.AddMinutes(2));
        }
예제 #7
0
        public async Task DonatorClaimDailyTest()
        {
            await using var unit = NewContext();
            var userService        = new UserService(unit, null);
            var transactionService = new TransactionService(userService);
            var dailyService       = new DailyService(unit, userService, transactionService);

            var response = await dailyService.ClaimDailyAsync(3L);

            var expectedClaimAmount = (AppProps.Daily.DailyAmount + AppProps.Daily.StreakAmount * 6) * 2;

            Assert.NotNull(response);
            Assert.Equal(6, response.CurrentStreak);
            Assert.Equal(10, response.LongestStreak);
            Assert.Equal(expectedClaimAmount, response.AmountClaimed);
            Assert.InRange(response.LastClaimTime, DateTime.UtcNow.AddMinutes(-2), DateTime.UtcNow.AddMinutes(2));
        }
예제 #8
0
        public static void loadFormSach(DataGridView gv)
        {
            int       stt   = 0;
            DataTable table = new DataTable();

            table.Columns.Add("STT", typeof(int));
            table.Columns.Add("Ma", typeof(int));
            table.Columns.Add("Tên", typeof(string));
            table.Columns.Add("Địa chỉ", typeof(string));
            table.Columns.Add("Mức nợ", typeof(decimal));
            var books = DailyService.GetAll();

            foreach (var item in books)
            {
                stt++;
                table.Rows.Add(stt, item.id, item.name, item.address, item.mucno);
            }
            gv.DataSource = table;
        }
예제 #9
0
        public async Task HigherThanHundredDailyTest()
        {
            await using var unit = NewContext();

            var userServiceMock = new Mock <IUserService>();

            userServiceMock.Setup(x => x.GetUserAsync(It.IsAny <long>()))
            .Returns(new ValueTask <User>(new User {
                Id = 5L
            }));
            var transactionServiceMock = new Mock <ITransactionService>();

            transactionServiceMock.Setup(x => x.CreateTransactionAsync(It.IsAny <TransactionRequest>()))
            .Returns(Task.FromResult(new TransactionResponse(null, null, 0)));

            var dailyService = new DailyService(
                unit, userServiceMock.Object, transactionServiceMock.Object);

            var dailyResponse = await dailyService.ClaimDailyAsync(5L);

            Assert.Equal(2100, dailyResponse.AmountClaimed);
        }
예제 #10
0
 public async Task GetDailyAsync()
 {
     DailyResultFlag result = DailyService.Next(Context.Account);
     await Context.Channel.SendMessageAsync(DailyService.ApplyAndDisplay(Context.Account, result));
 }
 public WeeklyStatisticController(WeeklyService weeklyService, DailyService dailyService)
 {
     _weeklyService = weeklyService;
     _dailyService  = dailyService;
 }
 public DailyController()
 {
     _dailyService = new DailyService(UserToken);
 }
예제 #13
0
        public void loadnxb(int?selected = null)
        {
            var nxbs = DailyService.GetAll();

            ViewBag.id_dl = new SelectList(nxbs, "id", "name", selected);
        }
예제 #14
0
 public DailyStatisticController(DailyService dailyStatisticService)
 {
     _dailyStatisticService = dailyStatisticService;
 }
예제 #15
0
 /// <summary>
 /// 需求分析:
 /// 1. 列表页,分页每页五个可以查找。
 /// 2. 添加,在添加的时候根据当天的日期判断当天的日记是否已经存在,如果已经存在那么就直接跳到编辑页面。
 /// 3. 编辑就是编辑。
 /// 4. 暂时没有删除。
 /// </summary>
 public DailyController()
 {
     _service = new DailyService();
 }