/// <summary> /// Sign-in and get member information /// </summary> /// <param name="param">SignIn Request Model</param> /// <remarks></remarks> public ProfileResultModel SignIn(SignInRequestModel param) { ProfileResultModel result = new ProfileResultModel(); if (!this.ModelState.IsValid) { result.Status = false; result.Message = this.ModelState.Values.Single(v => v.Errors.Count > 0).Errors.FirstOrDefault().ErrorMessage; return(result); } try { MemberBL bl = new MemberBL(); var member = bl.SignIn(param); if (member == null) { result.Status = false; result.Message = "Invalid user name"; } else { var token = IdentityHelper.GenerateToken(member); bl.RegisterToken(token); result.Status = true; result.Message = "Sign-in successfully"; result.Member = member; result.Member.AccessToken = token.Token; } } catch (OrgException oex) { result.Status = false; result.Message = oex.Message; } catch (Exception ex) { result.Status = false; result.Message = AppConfigs.InternalErrorMessage; if (AppConfigs.DebugInternalMessage) { result.InternalMessage = ex.Message; } } return(result); }