示例#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> Get(int id)
 {
     using (var context = new UserProfileDbContext())
     {
         return(Ok(await context.HocKies.Where(x => x.Id == id).Select(x => new HocKyDTO
         {
             Id = x.Id,
             TenHocKy = x.TenHocKy
         }).FirstOrDefaultAsync()));
     }
 }
 public async Task <IActionResult> Get()
 {
     using (var context = new UserProfileDbContext())
     {
         return(Ok(await context.TinhChatKhoanThus.Select(x => new TinhChatKhoanThuDTO
         {
             Id = x.Id,
             TenTinhChatKhoanThu = x.TenTinhChatKhoanThu
         }).ToListAsync()));
     }
 }
 public async Task <IActionResult> Get(int id)
 {
     using (var context = new UserProfileDbContext())
     {
         return(Ok(await context.TinhChatKhoanThus.Where(x => x.Id == id).Select(x => new TinhChatKhoanThuDTO
         {
             Id = x.Id,
             TenTinhChatKhoanThu = x.TenTinhChatKhoanThu
         }).FirstOrDefaultAsync()));
     }
 }
示例#5
0
 public async Task <IActionResult> Get(int id)
 {
     using (var context = new UserProfileDbContext())
     {
         return(Ok(await context.LoaiSanPhams.Where(x => x.Id == id).Select(x => new LoaiSanPhamDTO
         {
             Id = x.Id,
             TenLoaiSanPham = x.TenLoaiSanPham
         }).FirstOrDefaultAsync()));
     }
 }
示例#6
0
 public async Task <IActionResult> Get()
 {
     using (var context = new UserProfileDbContext())
     {
         return(Ok(await context.LoaiSanPhams.Select(x => new LoaiSanPhamDTO
         {
             Id = x.Id,
             TenLoaiSanPham = x.TenLoaiSanPham
         }).ToListAsync()));
     }
 }
示例#7
0
 public async Task <IActionResult> Get()
 {
     using (var context = new UserProfileDbContext())
     {
         return(Ok(await context.HocKies.Select(x => new HocKyDTO
         {
             Id = x.Id,
             TenHocKy = x.TenHocKy
         }).ToListAsync()));
     }
 }
 public async Task <IActionResult> Get()
 {
     using (var context = new UserProfileDbContext())
     {
         return(Ok(await context.Khois.Select(x => new KhoiDTO
         {
             Id = x.Id,
             TenKhoi = x.TenKhoi
         }).ToListAsync()));
     }
 }
 public async Task <IActionResult> Get()
 {
     using (var context = new UserProfileDbContext())
     {
         return(Ok(await context.HinhThucThus.Select(x => new HinhThucThuDTO
         {
             Id = x.Id,
             TenHinhThucThu = x.TenHinhThucThu,
             IdLoaiHinhThucThu = x.IdLoaiHinhThucThu
         }).ToListAsync()));
     }
 }
示例#10
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()));
     }
 }
示例#13
0
 public async Task <IActionResult> Get(int id)
 {
     using (var context = new UserProfileDbContext())
     {
         return(Ok(await context.LoaiKhoanChis.Where(x => x.Id == id).Select(x => new LoaiKhoanChiDTO
         {
             Id = x.Id,
             TenLoaiKhoanChi = x.TenLoaiKhoanChi,
             ThuTu = x.ThuTu,
             SuDung = x.SuDung
         }).FirstOrDefaultAsync()));
     }
 }
示例#14
0
 public async Task <IActionResult> Get()
 {
     using (var context = new UserProfileDbContext())
     {
         return(Ok(await context.LoaiKhoanChis.Select(x => new LoaiKhoanChiDTO
         {
             Id = x.Id,
             TenLoaiKhoanChi = x.TenLoaiKhoanChi,
             ThuTu = x.ThuTu,
             SuDung = x.SuDung
         }).ToListAsync()));
     }
 }
 public async Task <IActionResult> Get(int id)
 {
     using (var context = new UserProfileDbContext())
     {
         return(Ok(await context.HocSinhs.Where(x => x.Id == id).Select(x => new HocSinhDTO
         {
             Id = x.Id,
             TenHocSinh = x.TenHocSinh,
             NgaySinh = x.NgaySinh,
             GioiTinh = x.GioiTinh,
             IdLop = x.IdLop
         }).FirstOrDefaultAsync()));
     }
 }
 public async Task <IActionResult> Get(int id)
 {
     using (var context = new UserProfileDbContext())
     {
         return(Ok(await context.PhieuThus.Where(x => x.Id == id).Select(x => new PhieuThuDTO
         {
             Id = x.Id,
             NgayThu = x.NgayThu,
             TongTien = x.TongTien,
             IdNguoiThu = x.IdNguoiThu,
             IdChiTietPhieuThu = x.IdChiTietPhieuThu
         }).FirstOrDefaultAsync()));
     }
 }
 public async Task <IActionResult> Get()
 {
     using (var context = new UserProfileDbContext())
     {
         return(Ok(await context.HocSinhs.Select(x => new HocSinhDTO
         {
             Id = x.Id,
             TenHocSinh = x.TenHocSinh,
             NgaySinh = x.NgaySinh,
             GioiTinh = x.GioiTinh,
             IdLop = x.IdLop
         }).ToListAsync()));
     }
 }
 public async Task <IActionResult> Get(int id)
 {
     using (var context = new UserProfileDbContext())
     {
         return(Ok(await context.BaoCaoCongNos.Where(x => x.Id == id).Select(x => new BaoCaoCongNoDTO
         {
             Id = x.Id,
             CongNoHocPhi = x.CongNoHocPhi,
             CongNoDichVu = x.CongNoDichVu,
             TongCongNo = x.TongCongNo,
             IdHocSinh = x.IdHocSinh
         }).FirstOrDefaultAsync()));
     }
 }
 public async Task <IActionResult> Get(int id)
 {
     using (var context = new UserProfileDbContext())
     {
         return(Ok(await context.KhoanChiMienGiams.Where(x => x.Id == id).Select(x => new KhoanChiMienGiamDTO
         {
             Id = x.Id,
             TenKhoanChiMienGiam = x.TenKhoanChiMienGiam,
             SoTienMienGiam = x.SoTienMienGiam,
             GhiChu = x.GhiChu,
             IdKhoanChi = x.IdKhoanChi
         }).FirstOrDefaultAsync()));
     }
 }
        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> Get(int id)
 {
     using (var context = new UserProfileDbContext())
     {
         return Ok(await context.ChiTietPhieuThus.Where(x => x.Id == id).Select(x => new ChiTietPhieuThuDTO
         {
             Id = x.Id,
             TongTien = x.TongTien,
             KhauTru = x.KhauTru,
             DaThu = x.DaThu,
             SoTienBangChu = x.SoTienBangChu,
             IdHocSinh = x.IdHocSinh
         }).FirstOrDefaultAsync());
     }
 }
 public async Task <IActionResult> Get(int id)
 {
     using (var context = new UserProfileDbContext())
     {
         return(Ok(await context.BaoCaoDangKyDichVus.Where(x => x.Id == id).Select(x => new BaoCaoDangKyDichVuDTO
         {
             Id = x.Id,
             DonGia = x.DonGia,
             SoLuong = x.SoLuong,
             ThanhTien = x.ThanhTien,
             IdHocSinh = x.IdHocSinh,
             IdKhoanThuDichVu = x.IdKhoanThuDichVu
         }).FirstOrDefaultAsync()));
     }
 }
 public async Task <IActionResult> Get(int id)
 {
     using (var context = new UserProfileDbContext())
     {
         return(Ok(await context.DangKyDichVus.Where(x => x.Id == id).Select(x => new DangKyDichVuDTO
         {
             Id = x.Id,
             DonViTinh = x.DonViTinh,
             SoLuong = x.SoLuong,
             GhiChu = x.GhiChu,
             IdKhoanThuDichVu = x.IdKhoanThuDichVu,
             IdHocSinh = x.IdHocSinh,
             IdDotThu = x.IdDotThu
         }).FirstOrDefaultAsync()));
     }
 }
示例#24
0
 public async Task <IActionResult> Get(int id)
 {
     using (var context = new UserProfileDbContext())
     {
         return(Ok(await context.KhoanThuCoDinhs.Where(x => x.Id == id).Select(x => new KhoanThuCoDinhDTO
         {
             Id = x.Id,
             TenKhoanThuCoDinh = x.TenKhoanThuCoDinh,
             DonGia = x.DonGia,
             ThuTu = x.ThuTu,
             GhiChu = x.GhiChu,
             SuDung = x.SuDung,
             IdLoaiKhoanThu = x.IdLoaiKhoanThu
         }).FirstOrDefaultAsync()));
     }
 }
 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] 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()));
     }
 }
        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()));
            }
        }
示例#28
0
 public async Task <IActionResult> Get(int id)
 {
     using (var context = new UserProfileDbContext())
     {
         return(Ok(await context.KhoanThuBanHangs.Where(x => x.Id == id).Select(x => new KhoanThuBanHangDTO
         {
             Id = x.Id,
             TenSanPham = x.TenSanPham,
             DonGia = x.DonGia,
             ThuTu = x.ThuTu,
             SuDung = x.SuDung,
             IdLoaiKhoanThu = x.IdLoaiKhoanThu,
             IdLoaiSanPham = x.IdLoaiSanPham
         }).FirstOrDefaultAsync()));
     }
 }
示例#29
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] 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 ActionResult ResetPassword3(string username, string resetToken)
        {
            UserProfileDbContext db = new UserProfileDbContext();
            //TODO: Check the un and rt matching and then perform following
            //get userid of received username
            var userid = (from i in db.UserProfile
                          where i.UserName == username
                          select i.UserId).FirstOrDefault();
            //check userid and token matches
            bool any = (from j in db.webpages_Memberships
                        where (j.UserId == userid)
                        && (j.PasswordVerificationToken == resetToken)
                        //&& (j.PasswordVerificationTokenExpirationDate < DateTime.Now)
                        select j).Any();

            if (any == true)
            {
                //generate random password
                string newpassword = GenerateRandomPassword(6);
                //reset password
                bool response = WebSecurity.ResetPassword(resetToken, newpassword);
                if (response == true)
                {
                    //get user emailid to send password
                    var EmailAddress = (from i in db.UserProfile
                                        where i.UserName == username
                                        select i.EmailAddress).FirstOrDefault();
                    //send email
                    string subject = "New Password for your Bookteria Account";
                    string body = "<b>Your New Password is </b>" + newpassword  + " <b>Please make sure you change it after succesfull Log in. </b></br>";
                    try
                    {
                        SendEMail(EmailAddress, subject, body);
                        TempData["Message"] = "Mail Sent.";
                    }
                    catch (Exception ex)
                    {
                        TempData["Message"] = "Error occured while sending email." + ex.Message;
                    }

                    //display message
                    TempData["Message"] = "Success! Check email we sent for your new Password!";
                }
                else
                {
                    TempData["Message"] = "Hey, avoid random request on this page.";
                }
            }
            else
            {
                TempData["Message"] = "Username and token not maching.";
            }

            return View();
        }
        public ActionResult ExternalLoginConfirmation(RegisterExternalLoginModel model, string returnUrl)
        {
            string provider = null;
            string providerUserId = null;

            if (User.Identity.IsAuthenticated || !OAuthWebSecurity.TryDeserializeProviderUserId(model.ExternalLoginData, out provider, out providerUserId))
            {
                return RedirectToAction("Manage");
            }

            if (ModelState.IsValid)
            {
                // Insert a new user into the database
                using (var db = new UserProfileDbContext())
                {
                    UserProfile user = db.UserProfile.FirstOrDefault(u => u.UserName.ToLower() == model.UserName.ToLower());
                    // Check if user already exists
                    if (user == null)
                    {
                        // Insert name into the profile table
                        db.UserProfile.Add(new UserProfile { UserName = model.UserName });
                        db.SaveChanges();

                        OAuthWebSecurity.CreateOrUpdateAccount(provider, providerUserId, model.UserName);
                        OAuthWebSecurity.Login(provider, providerUserId, createPersistentCookie: false);

                        return RedirectToLocal(returnUrl);
                    }
                    else
                    {
                        ModelState.AddModelError("UserName", "User name already exists. Please enter a different user name.");
                    }
                }
            }

            ViewBag.ProviderDisplayName = OAuthWebSecurity.GetOAuthClientData(provider).DisplayName;
            ViewBag.ReturnUrl = returnUrl;
            return View(model);
        }