예제 #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()));
            }
        }
예제 #2
0
 public async Task <IActionResult> Post([FromBody] LoaiSanPhamDTO model)
 {
     using (var context = new UserProfileDbContext())
     {
         context.LoaiSanPhams.Add(new LoaiSanPham
         {
             Id             = model.Id,
             TenLoaiSanPham = model.TenLoaiSanPham
         });
         //context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[UserProfiles] ON");
         return(Ok(await context.SaveChangesAsync()));
     }
 }
        public async Task<IActionResult> Delete(int id)
        {
            using (var context = new UserProfileDbContext())
            {
                var user = await context.ChiTietPhieuThus.FindAsync(id);

                if (user == null) return NotFound();

                context.Entry(user).State = EntityState.Deleted;

                return Ok(await context.SaveChangesAsync());
            }
        }
 public async Task <IActionResult> Post([FromBody] TinhChatKhoanThuDTO model)
 {
     using (var context = new UserProfileDbContext())
     {
         context.TinhChatKhoanThus.Add(new TinhChatKhoanThu
         {
             Id = model.Id,
             TenTinhChatKhoanThu = model.TenTinhChatKhoanThu
         });
         //context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[UserProfiles] ON");
         return(Ok(await context.SaveChangesAsync()));
     }
 }
예제 #5
0
        public async Task <bool> UserActivation(UserActivationDto activationDto)
        {
            using (var _activateTrans = _userProfileDbContext.Database.BeginTransaction())
            {
                var activate = await _userProfileDbContext.UserActivationModel.FirstOrDefaultAsync(a => a.ActivationCode == activationDto.ActivationCode &&
                                                                                                   a.UserModelId == activationDto.UserId);

                if (activate != null)
                {
                    //check if code has expired
                    var checkTime = activate.ExpiresAt >= (DateTime.UtcNow) ? true : false;
                    if (checkTime)
                    {
                        //delete the code from the database
                        _userProfileDbContext.Remove(activate);
                        await _userProfileDbContext.SaveChangesAsync();

                        //update user table with statuses
                        var user = await _userProfileDbContext.UserModel.FirstOrDefaultAsync(u => u.Id == activationDto.UserId);

                        if (user != null)
                        {
                            user.IsActivated = true;
                            user.IsActive    = true;

                            _userProfileDbContext.Entry(user).State = EntityState.Modified;
                            await _userProfileDbContext.SaveChangesAsync();
                        }

                        //commit to database
                        _activateTrans.Commit();

                        return(true);
                    }
                    return(false);
                }
            }
            return(false);
        }
        public async Task <IActionResult> Put(int id, [FromBody] TinhChatKhoanThuDTO model)
        {
            using (var context = new UserProfileDbContext())
            {
                var user = await context.TinhChatKhoanThus.FirstOrDefaultAsync(x => x.Id.Equals(id));

                if (user == null)
                {
                    return(NotFound());
                }
                user.Id = model.Id;
                user.TenTinhChatKhoanThu = model.TenTinhChatKhoanThu;
                return(Ok(await context.SaveChangesAsync()));
            }
        }
 public async Task <IActionResult> Post([FromBody] BaoCaoCongNoDTO model)
 {
     using (var context = new UserProfileDbContext())
     {
         context.BaoCaoCongNos.Add(new BaoCaoCongNo
         {
             Id           = model.Id,
             CongNoHocPhi = model.CongNoHocPhi,
             CongNoDichVu = model.CongNoDichVu,
             TongCongNo   = model.TongCongNo,
             IdHocSinh    = model.IdHocSinh
         });
         //context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[UserProfiles] ON");
         return(Ok(await context.SaveChangesAsync()));
     }
 }
예제 #8
0
 public async Task <IActionResult> Post([FromBody] KhoanChiDTO model)
 {
     using (var context = new UserProfileDbContext())
     {
         context.KhoanChis.Add(new KhoanChi
         {
             Id             = model.Id,
             TenKhoanChi    = model.TenKhoanChi,
             ThuTu          = model.ThuTu,
             SuDung         = model.SuDung,
             IdLoaiKhoanChi = model.IdLoaiKhoanChi
         });
         //context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[UserProfiles] ON");
         return(Ok(await context.SaveChangesAsync()));
     }
 }
 public async Task <IActionResult> Post([FromBody] KhoanChiMienGiamDTO model)
 {
     using (var context = new UserProfileDbContext())
     {
         context.KhoanChiMienGiams.Add(new KhoanChiMienGiam
         {
             Id = model.Id,
             TenKhoanChiMienGiam = model.TenKhoanChiMienGiam,
             SoTienMienGiam      = model.SoTienMienGiam,
             GhiChu     = model.GhiChu,
             IdKhoanChi = model.IdKhoanChi
         });
         //context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[UserProfiles] ON");
         return(Ok(await context.SaveChangesAsync()));
     }
 }
 public async Task <IActionResult> Post([FromBody] HocSinhDTO model)
 {
     using (var context = new UserProfileDbContext())
     {
         context.HocSinhs.Add(new HocSinh
         {
             Id         = model.Id,
             TenHocSinh = model.TenHocSinh,
             NgaySinh   = model.NgaySinh,
             GioiTinh   = model.GioiTinh,
             IdLop      = model.IdLop
         });
         //context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[UserProfiles] ON");
         return(Ok(await context.SaveChangesAsync()));
     }
 }
        public async Task<IActionResult> Put(int id, [FromBody] ChiTietPhieuThuDTO model)
        {
            using (var context = new UserProfileDbContext())
            {
                var user = await context.ChiTietPhieuThus.FirstOrDefaultAsync(x => x.Id.Equals(id));

                if (user == null) return NotFound();
                user.Id = model.Id;
                user.TongTien = model.TongTien;
                user.KhauTru = model.KhauTru;
                user.DaThu = model.DaThu;
                user.SoTienBangChu = model.SoTienBangChu;
                user.IdHocSinh = model.IdHocSinh;
                return Ok(await context.SaveChangesAsync());
            }
        }
 public async Task <IActionResult> Post([FromBody] PhieuThuDTO model)
 {
     using (var context = new UserProfileDbContext())
     {
         context.PhieuThus.Add(new PhieuThu
         {
             Id                = model.Id,
             NgayThu           = model.NgayThu,
             TongTien          = model.TongTien,
             IdNguoiThu        = model.IdNguoiThu,
             IdChiTietPhieuThu = model.IdChiTietPhieuThu
         });
         //context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[UserProfiles] ON");
         return(Ok(await context.SaveChangesAsync()));
     }
 }
        public async Task <IActionResult> Delete(int id)
        {
            using (var context = new UserProfileDbContext())
            {
                var user = await context.TinhChatKhoanThus.FindAsync(id);

                if (user == null)
                {
                    return(NotFound());
                }

                context.Entry(user).State = EntityState.Deleted;

                return(Ok(await context.SaveChangesAsync()));
            }
        }
 public async Task<IActionResult> Post([FromBody] ChiTietPhieuThuDTO model)
 {
     using (var context = new UserProfileDbContext())
     {
         context.ChiTietPhieuThus.Add(new ChiTietPhieuThu
         {
             Id = model.Id,
             TongTien = model.TongTien,
             KhauTru = model.KhauTru,
             DaThu = model.DaThu,
             SoTienBangChu = model.SoTienBangChu,
             IdHocSinh = model.IdHocSinh
         });
         //context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[UserProfiles] ON");
         return Ok(await context.SaveChangesAsync());
     }
 }
예제 #15
0
        public async Task <IActionResult> Put(int id, [FromBody] LoaiKhoanChiDTO model)
        {
            using (var context = new UserProfileDbContext())
            {
                var user = await context.LoaiKhoanChis.FirstOrDefaultAsync(x => x.Id.Equals(id));

                if (user == null)
                {
                    return(NotFound());
                }
                user.Id = model.Id;
                user.TenLoaiKhoanChi = model.TenLoaiKhoanChi;
                user.ThuTu           = model.ThuTu;
                user.SuDung          = model.SuDung;
                return(Ok(await context.SaveChangesAsync()));
            }
        }
 public async Task <IActionResult> Post([FromBody] BaoCaoDangKyDichVuDTO model)
 {
     using (var context = new UserProfileDbContext())
     {
         context.BaoCaoDangKyDichVus.Add(new BaoCaoDangKyDichVu
         {
             Id               = model.Id,
             DonGia           = model.DonGia,
             SoLuong          = model.SoLuong,
             ThanhTien        = model.ThanhTien,
             IdHocSinh        = model.IdHocSinh,
             IdKhoanThuDichVu = model.IdKhoanThuDichVu
         });
         //context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[UserProfiles] ON");
         return(Ok(await context.SaveChangesAsync()));
     }
 }
        public async Task <IActionResult> Put(int id, [FromBody] KhoanChiMienGiamDTO model)
        {
            using (var context = new UserProfileDbContext())
            {
                var user = await context.KhoanChiMienGiams.FirstOrDefaultAsync(x => x.Id.Equals(id));

                if (user == null)
                {
                    return(NotFound());
                }
                user.Id = model.Id;
                user.TenKhoanChiMienGiam = model.TenKhoanChiMienGiam;
                user.SoTienMienGiam      = model.SoTienMienGiam;
                user.GhiChu     = model.GhiChu;
                user.IdKhoanChi = model.IdKhoanChi;
                return(Ok(await context.SaveChangesAsync()));
            }
        }
        public async Task <IActionResult> Put(int id, [FromBody] PhieuThuDTO model)
        {
            using (var context = new UserProfileDbContext())
            {
                var user = await context.PhieuThus.FirstOrDefaultAsync(x => x.Id.Equals(id));

                if (user == null)
                {
                    return(NotFound());
                }
                user.Id                = model.Id;
                user.NgayThu           = model.NgayThu;
                user.TongTien          = model.TongTien;
                user.IdNguoiThu        = model.IdNguoiThu;
                user.IdChiTietPhieuThu = model.IdChiTietPhieuThu;
                return(Ok(await context.SaveChangesAsync()));
            }
        }
        public async Task <IActionResult> Put(int id, [FromBody] BaoCaoCongNoDTO model)
        {
            using (var context = new UserProfileDbContext())
            {
                var user = await context.BaoCaoCongNos.FirstOrDefaultAsync(x => x.Id.Equals(id));

                if (user == null)
                {
                    return(NotFound());
                }
                user.Id           = model.Id;
                user.CongNoHocPhi = model.CongNoHocPhi;
                user.CongNoDichVu = model.CongNoDichVu;
                user.TongCongNo   = model.TongCongNo;
                user.IdHocSinh    = model.IdHocSinh;
                return(Ok(await context.SaveChangesAsync()));
            }
        }
        public async Task <IActionResult> Put(int id, [FromBody] HocSinhDTO model)
        {
            using (var context = new UserProfileDbContext())
            {
                var user = await context.HocSinhs.FirstOrDefaultAsync(x => x.Id.Equals(id));

                if (user == null)
                {
                    return(NotFound());
                }
                user.Id         = model.Id;
                user.TenHocSinh = model.TenHocSinh;
                user.NgaySinh   = model.NgaySinh;
                user.GioiTinh   = model.GioiTinh;
                user.IdLop      = model.IdLop;
                return(Ok(await context.SaveChangesAsync()));
            }
        }
        public async Task <IActionResult> Put(int id, [FromBody] BaoCaoDangKyDichVuDTO model)
        {
            using (var context = new UserProfileDbContext())
            {
                var user = await context.BaoCaoDangKyDichVus.FirstOrDefaultAsync(x => x.Id.Equals(id));

                if (user == null)
                {
                    return(NotFound());
                }
                user.Id               = model.Id;
                user.DonGia           = model.DonGia;
                user.SoLuong          = model.SoLuong;
                user.ThanhTien        = model.ThanhTien;
                user.IdHocSinh        = model.IdHocSinh;
                user.IdKhoanThuDichVu = model.IdKhoanThuDichVu;
                return(Ok(await context.SaveChangesAsync()));
            }
        }
 public async Task <IActionResult> Post([FromBody] KeHoachThuDTO model)
 {
     using (var context = new UserProfileDbContext())
     {
         context.KeHoachThus.Add(new KeHoachThu
         {
             Id               = model.Id,
             SoTien           = model.SoTien,
             GhiChu           = model.GhiChu,
             SoLuongHocSinh   = model.SoLuongHocSinh,
             BatBuoc          = model.BatBuoc,
             IdHocKy          = model.IdHocKy,
             IdKhoi           = model.IdKhoi,
             IdHinhThucThu    = model.IdHinhThucThu,
             IdKhoanThuCoDinh = model.IdKhoanThuCoDinh,
         });
         //context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[UserProfiles] ON");
         return(Ok(await context.SaveChangesAsync()));
     }
 }
예제 #23
0
        public async Task <IActionResult> Put(int id, [FromBody] KhoanThuBanHangDTO model)
        {
            using (var context = new UserProfileDbContext())
            {
                var user = await context.KhoanThuBanHangs.FirstOrDefaultAsync(x => x.Id.Equals(id));

                if (user == null)
                {
                    return(NotFound());
                }
                user.Id             = model.Id;
                user.TenSanPham     = model.TenSanPham;
                user.DonGia         = model.DonGia;
                user.ThuTu          = model.ThuTu;
                user.SuDung         = model.SuDung;
                user.IdLoaiKhoanThu = model.IdLoaiKhoanThu;
                user.IdLoaiSanPham  = model.IdLoaiSanPham;
                return(Ok(await context.SaveChangesAsync()));
            }
        }
 public async Task <IActionResult> Post([FromBody] UserProfileDTO model)
 {
     using (var context = new UserProfileDbContext())
     {
         context.UserProfiles.Add(new UserProfile
         {
             Id        = model.Id,
             Username  = model.Username,
             Email     = model.Email,
             Firstname = model.Firstname,
             Lastname  = model.Lastname,
             Address   = model.Address,
             City      = model.City,
             Country   = model.Country,
             Salary    = model.Salary,
             AboutMe   = model.AboutMe
         });
         //context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[UserProfiles] ON");
         return(Ok(await context.SaveChangesAsync()));
     }
 }
 public async Task <IActionResult> Post([FromBody] KhoanThuDichVuDTO model)
 {
     using (var context = new UserProfileDbContext())
     {
         context.KhoanThuDichVus.Add(new KhoanThuDichVu
         {
             Id = model.Id,
             TenKhoanThuDichVu = model.TenKhoanThuDichVu,
             DonGia            = model.DonGia,
             ThuTu             = model.ThuTu,
             DonGiaTra         = model.DonGiaTra,
             GhiChu            = model.GhiChu,
             SuDung            = model.SuDung,
             TinhTheoNgay      = model.TinhTheoNgay,
             TraLaiKhiVang     = model.TraLaiKhiVang,
             IdLoaiKhoanThu    = model.IdLoaiKhoanThu
         });
         //context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[UserProfiles] ON");
         return(Ok(await context.SaveChangesAsync()));
     }
 }
        public async Task <IActionResult> Put(int id, [FromBody] KeHoachThuDTO model)
        {
            using (var context = new UserProfileDbContext())
            {
                var user = await context.KeHoachThus.FirstOrDefaultAsync(x => x.Id.Equals(id));

                if (user == null)
                {
                    return(NotFound());
                }
                user.Id               = model.Id;
                user.SoTien           = model.SoTien;
                user.GhiChu           = model.GhiChu;
                user.SoLuongHocSinh   = model.SoLuongHocSinh;
                user.BatBuoc          = model.BatBuoc;
                user.IdHocKy          = model.IdHocKy;
                user.IdKhoi           = model.IdKhoi;
                user.IdHinhThucThu    = model.IdHinhThucThu;
                user.IdKhoanThuCoDinh = model.IdKhoanThuCoDinh;
                return(Ok(await context.SaveChangesAsync()));
            }
        }
        public async Task <IActionResult> Put(int id, [FromBody] KhoanThuDichVuDTO model)
        {
            using (var context = new UserProfileDbContext())
            {
                var user = await context.KhoanThuDichVus.FirstOrDefaultAsync(x => x.Id.Equals(id));

                if (user == null)
                {
                    return(NotFound());
                }
                user.Id = model.Id;
                user.TenKhoanThuDichVu = model.TenKhoanThuDichVu;
                user.DonGia            = model.DonGia;
                user.ThuTu             = model.ThuTu;
                user.DonGiaTra         = model.DonGiaTra;
                user.GhiChu            = model.GhiChu;
                user.SuDung            = model.SuDung;
                user.TinhTheoNgay      = model.TinhTheoNgay;
                user.TraLaiKhiVang     = model.TraLaiKhiVang;
                user.IdLoaiKhoanThu    = model.IdLoaiKhoanThu;
                return(Ok(await context.SaveChangesAsync()));
            }
        }
        public async Task <IActionResult> Put(int id, [FromBody] UserProfileDTO model)
        {
            using (var context = new UserProfileDbContext())
            {
                var user = await context.UserProfiles.FirstOrDefaultAsync(x => x.Id.Equals(id));

                if (user == null)
                {
                    return(NotFound());
                }
                user.Id        = model.Id;
                user.Username  = model.Username;
                user.Email     = model.Email;
                user.Firstname = model.Firstname;
                user.Lastname  = model.Lastname;
                user.Address   = model.Address;
                user.City      = model.City;
                user.Country   = model.Country;
                user.Salary    = model.Salary;
                user.AboutMe   = model.AboutMe;
                return(Ok(await context.SaveChangesAsync()));
            }
        }
예제 #29
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()));
     }
 }