public IHttpActionResult AdminGetListBacker(string code) { var listBacker = new BackingDTO(); try { // Check authen. if (User.Identity == null || !User.Identity.IsAuthenticated) { return Ok(new HttpMessageDTO { Status = DDLConstants.HttpMessageType.ERROR, Message = "", Type = DDLConstants.HttpMessageType.NOT_AUTHEN }); } // Check role user. var currentUser = UserRepository.Instance.GetBasicInfo(User.Identity.Name); if (currentUser == null || currentUser.Role != DDLConstants.UserType.ADMIN) { throw new NotPermissionException(); } listBacker = ProjectRepository.Instance.GetListBacker(code); } catch (Exception) { return Ok(new HttpMessageDTO { Status = DDLConstants.HttpMessageType.ERROR, Message = "", Type = DDLConstants.HttpMessageType.BAD_REQUEST }); } return Ok(new HttpMessageDTO { Status = "success", Message = "", Type = "", Data = listBacker }); }
public IHttpActionResult GetListBacker(string code) { var listBacker = new BackingDTO(); try { listBacker = ProjectRepository.Instance.GetListBacker(code); } catch (UserNotFoundException) { return Ok(new HttpMessageDTO { Status = DDLConstants.HttpMessageType.ERROR, Message = "Bạn chưa đăng nhập!", Type = DDLConstants.HttpMessageType.NOT_FOUND }); } catch (Exception) { return Ok(new HttpMessageDTO { Status = DDLConstants.HttpMessageType.ERROR, Message = "", Type = DDLConstants.HttpMessageType.BAD_REQUEST }); } return Ok(new HttpMessageDTO { Status = "success", Message = "", Type = "", Data = listBacker }); }