public BaseResponseModel <LoginOutPut> UserLogin(LoginModel loginModel) { string errMsg = string.Empty; LoginOutPut loginOutPut = new LoginOutPut(); try { //验证提交数据合法性 UserDataLegalityVerification(loginModel); loginOutPut = userService.UserLogin(loginModel); } catch (VerificationException ex) { loginOutPut.remindMsg = ex.Message; } catch (OperationException ex) { errMsg = ex.Message; } catch (Exception ex) { errMsg = ex.Message; } return(ResponsePack.Responsing(loginOutPut, errMeassage: errMsg)); }
private static void SetPublicFields(Type type, object obj, Dictionary <Type, object> createdObjectReferences) { LoginOutPut loginOutPut = new LoginOutPut(); obj = loginOutPut; FieldInfo[] fields = type.GetFields(BindingFlags.Public | BindingFlags.Instance); ObjectGenerator objectGenerator = new ObjectGenerator(); foreach (FieldInfo field in fields) { object fieldValue = objectGenerator.GenerateObject(field.FieldType, createdObjectReferences); field.SetValue(obj, fieldValue); } }
public IHttpActionResult GetAllUser() { try { //query = @"SELECT roles,mobile,department,lang,docType,name,email,userPhoto,prevPass,`password`,mobNum,telNum // From " + _bucket.Name + " as `loginDetails` where meta().id like'login_%' " + // " and isActive=true and docType='user'"; query = @"SELECT roles,department,lang,docType,name,email,userPhoto,prevPass,`password`,mobNum,telNum From " + _bucket.Name + " as `loginDetails` where meta().id like'login_%' and isActive=true and docType='user' "; var users = _bucket.Query <LoginOutPut>(query).ToList(); if (users.Count == 0) { return(Content(HttpStatusCode.NotFound, MessageResponse.Message(HttpStatusCode.NotFound.ToString(), MessageDescriptions.NotFound, "record not found."), new JsonMediaTypeFormatter())); } else { //return Content(HttpStatusCode.OK, users); LoginOutPut loginOutPut = new LoginOutPut(); List <LoginOutPut> stLogin = new List <LoginOutPut>(); bool IsDepartmentNotFound = false; foreach (var item1 in users) { loginOutPut = new LoginOutPut(); //Other Roles List <OtherRoleOutPut> othoutPut = new List <OtherRoleOutPut>(); List <string> lstDept = new List <string>(); if (item1.Roles.OtherRoles != null) { foreach (var or in item1.Roles.OtherRoles) { IsDepartmentNotFound = false; var objOtherRolesDetails = _bucket.Query <object>(@"SELECT r.* FROM APTCREF AS d USE KEYS[""REF_EN_US""] UNNEST d.['Role'] AS r").ToList(); foreach (var item in objOtherRolesDetails) { if (((Newtonsoft.Json.Linq.JToken)item).Root["Roles"] != null) { foreach (var itemRoles in ((Newtonsoft.Json.Linq.JToken)item).Root["Roles"]) { if (itemRoles["Code"] != null) { if (itemRoles["Code"].ToString().ToUpper() == or.Name.ToString().ToUpper()) { if (((Newtonsoft.Json.Linq.JToken)item).Root["Val"] != null) { IsDepartmentNotFound = true; or.Department = ((Newtonsoft.Json.Linq.JToken)item).Root["Val"].ToString(); othoutPut.Add(or); } } } } } } if (IsDepartmentNotFound == false) { othoutPut.Add(or); } item1.Roles.OtherRoles = othoutPut; } loginOutPut = item1; } else { loginOutPut = item1; } stLogin.Add(loginOutPut); } return(Content(HttpStatusCode.OK, stLogin)); } //List<object> lstObj = new List<object>(); //string queryLogin = string.Empty; //string query = @"SELECT email,docType,address,dob,documents,gender,isActive,keyID,language,fullName,auditInfo // ,maritalStatus,notes,nationality,religion,mobNum,telNum From " + _bucket.Name + " as `personelInformation` where meta().id like'user_%' and isActive=true "; //var userDocument = _bucket.Query<UserDetails>(query).ToList(); //if (userDocument.Count == 0) //{ // return Content(HttpStatusCode.NotFound, MessageResponse.Message(HttpStatusCode.NotFound.ToString(), MessageDescriptions.NotFound, ""), new JsonMediaTypeFormatter()); //} //foreach (var item in userDocument) //{ // queryLogin = @"SELECT emirateId,roles,department From " + _bucket.Name + " as `loginDetails` where meta().id like'login_%' and isActive=true and email='" + item.Email + "'"; // var loginDocument = _bucket.Query<Login>(queryLogin).ToList(); // foreach (var login in loginDocument) // { // item.emirateId = login.EmirateId; // item.Department = login.Department; // item.PrimaryRole = login.Roles.PrimaryRole; // item.otherRoles = login.Roles.OtherRoles; // } // query = @"SELECT docImage From " + _bucket.Name + " as `documents` where meta().id like'DOCIN%' and docType like'%profilephoto%' and indivID='" + item.KeyID + "' and status=true"; // var docDocument = _bucket.Query<object>(query).ToList(); // foreach (var doc in docDocument) // { // item.ProfilePhoto = ((Newtonsoft.Json.Linq.JContainer)doc)["docImage"].ToString(); // } // lstObj.Add(item); //} //return Content(HttpStatusCode.OK, users); } catch (Exception ex) { return(Content(HttpStatusCode.InternalServerError, MessageResponse.Message(HttpStatusCode.InternalServerError.ToString(), ex.StackTrace), new JsonMediaTypeFormatter())); } }