Exemple #1
0
        public async Task <IActionResult> Put(int id, [FromBody] ThuHocPhiDTO model)
        {
            using (var context = new UserProfileDbContext())
            {
                var user = await context.ThuHocPhis.FirstOrDefaultAsync(x => x.Id.Equals(id));

                if (user == null)
                {
                    return(NotFound());
                }
                user.Id = model.Id;
                user.IdKhoanThuCoDinh   = model.IdKhoanThuCoDinh;
                user.IdKhoanThuDichVu   = model.IdKhoanThuDichVu;
                user.IdKhoanThuBanHang  = model.IdKhoanThuBanHang;
                user.IdHocKy            = model.IdHocKy;
                user.IdKhoanChiMienGiam = model.IdKhoanChiMienGiam;
                user.SoLuong1           = model.SoLuong1;
                user.SoLuong2           = model.SoLuong2;
                user.SoLuong3           = model.SoLuong3;
                user.NgayThu            = model.NgayThu;
                user.IdNguoiThu         = model.IdNguoiThu;
                user.IdHocSinh          = model.IdHocSinh;
                user.IdHinhThucThu      = model.IdHinhThucThu;
                return(Ok(await context.SaveChangesAsync()));
            }
        }
Exemple #2
0
 public async Task <IActionResult> Post([FromBody] ThuHocPhiDTO model)
 {
     using (var context = new UserProfileDbContext())
     {
         context.ThuHocPhis.Add(new ThuHocPhi
         {
             Id = model.Id,
             IdKhoanThuCoDinh   = model.IdKhoanThuCoDinh,
             IdKhoanThuDichVu   = model.IdKhoanThuDichVu,
             IdKhoanThuBanHang  = model.IdKhoanThuBanHang,
             IdHocKy            = model.IdHocKy,
             IdKhoanChiMienGiam = model.IdKhoanChiMienGiam,
             SoLuong1           = model.SoLuong1,
             SoLuong2           = model.SoLuong2,
             SoLuong3           = model.SoLuong3,
             NgayThu            = model.NgayThu,
             IdNguoiThu         = model.IdNguoiThu,
             IdHocSinh          = model.IdHocSinh,
             IdHinhThucThu      = model.IdHinhThucThu
         });
         //context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[UserProfiles] ON");
         return(Ok(await context.SaveChangesAsync()));
     }
 }