Exemplo n.º 1
0
        public ActionResult Authen(string Username, string Password)
        {
            var model = new NhanVienVM
            {
                TenDangNhap = Username,
                MatKhau     = Password
            };

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:49497/api/");
                var response = client.PostAsJsonAsync("nhanvien", model);
                response.Wait();

                var result = response.Result;
                if (result.IsSuccessStatusCode)
                {
                    var read = result.Content.ReadAsAsync <NhanVienVM>();
                    read.Wait();
                    NhanVienVM user = read.Result;
                    //Session["LaQuanLy"] = user.LaQuanLy;
                    if (user.LaQuanLy)
                    {
                        Session["UserType"] = "Manager";
                    }
                    else
                    {
                        Session["UserType"] = "Clerk";
                    }
                    if (user != null)
                    {
                        return(RedirectToAction("QuanLyKhachHang", "Manager"));
                    }
                }
            }
            //if (Username == "vung" && Password == "123")
            //{
            //    return RedirectToAction("QuanLyKhachHang", "Manager");
            //}
            return(View());
        }
        public async Task <IActionResult> Details(int?id)
        {
            var nhanVien = await _context.NhanVien
                           .FirstOrDefaultAsync(m => m.id_NhanVien == id);

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

            NhanVienVM model = new NhanVienVM()
            {
                NhanVien  = nhanVien,
                GioiThieu = nhanVien.GioiThieu == null ? new List <string>() : nhanVien.GioiThieu.Split("\n").ToList(),
                HocVan    = nhanVien.HocVan == null ? new List <string>() : nhanVien.HocVan.Split(",").ToList(),
                ChungChi  = nhanVien.ChungChi == null ? new List <string>() : nhanVien.ChungChi.Split(",").ToList(),
                KyNang    = nhanVien.KyNang == null ? new List <string>() : nhanVien.KyNang.Split(",").ToList(),
                SoThich   = nhanVien.SoThich == null ? new List <string>() : nhanVien.SoThich.Split(",").ToList()
            };

            return(View(model));
        }