예제 #1
0
        public IHttpActionResult GetByUserId(string userId, int tinhTrang)
        {
            if (string.IsNullOrEmpty(userId))
            {
                return(BadRequest());
            }
            EnumTinhTrang enumTinh = (EnumTinhTrang)tinhTrang;
            var           muontra  = _muonTraService.Gets(p => p.UserId == userId && p.TinhTrang == enumTinh).ToList().Select(Mapper.Map <MuonTra, MuonTraDto>);

            if (muontra == null)
            {
                return(NotFound());
            }
            return(Ok(muontra));
        }
예제 #2
0
        public async Task <ActionResult> Delete(string id)
        {
            var user = await _userService.GetUserById(id);

            var muonTras = _muonTraService.Gets(p => p.UserId == id);

            if (muonTras.Count() > 0)
            {
                TempData["AlertMessage"] = "Cập nhật avatar thành công";
                return(RedirectToAction("IndexAsync"));
            }
            _functionLichSuHoatDongService.Create(ActionWithObject.Delete, User.Identity.GetUserId(), "tài khoản: " + user.UserName);
            await _userService.DeleteAsync(user);

            TempData["AlertMessage"] = "Xóa Thành Công";
            return(RedirectToAction("IndexAsync"));
        }
예제 #3
0
        public async Task <ActionResult> UserProfile()
        {
            string id = User.Identity.GetUserId();

            var user = await _userService.GetUserById(id);

            var roles = await _userService.GetRolesForUser(id);

            var model = new UserViewModel(user)
            {
                Role = roles.Count() > 0 ? roles[0].ToString() : ""
            };

            ViewBag.MuonTras = _muonTraService.Gets(p => p.UserId == id && p.TinhTrang == EnumTinhTrang.DangMuon);

            return(View(model));
        }