internal protected void SetId(JRaw value) { if (value == null || string.IsNullOrWhiteSpace(value.ToString())) { return; } var jObj = JObject.Parse(value.ToString()); Id = jObj.GetIdDynamic() ?? Id; }
internal protected void SetRelatedId(JRaw value) { if (value == null || string.IsNullOrWhiteSpace(value.ToString())) { return; } var jObj = JObject.Parse(value.ToString()); RelatedId = jObj.GetValue(RelatedIdProperty)?.ToString() ?? RelatedId; }
public static JToken GetValue(this JRaw jRaw, string property) { if (jRaw == null) { throw new ArgumentNullException("jRaw", string.Format(Constants.ObjectNullException, "jRaw")); } if (string.IsNullOrWhiteSpace(property)) { throw new ArgumentNullException("property", string.Format(Constants.StringNullException, "property")); } var json = jRaw.ToString(); if (string.IsNullOrWhiteSpace(json)) { throw new ArgumentNullException("jRaw", string.Format(Constants.StringNullException, "jRaw")); } var jObj = JObject.Parse(json); return(jObj.GetValue(property)); }
public EventData ToData() { return(new EventData(Type, Metadata, Payload.ToString(CultureInfo.InvariantCulture))); }
public JRawValue(JRaw value) { _value = value.ToString(); }
public static T DeserializeInto <T>(this JRaw jRaw) => JsonConvert.DeserializeObject <T>(jRaw.ToString());
public async Task <ActionResult <object> > ValidateUserRole([FromBody] JRaw u)// "{"email":"","password":""}" { // string pwd = ""; JObject stuff = JObject.Parse(u.ToString()); string email = stuff["email"].ToString(); string pwd = stuff["password"].ToString(); var result = await _signInManager.PasswordSignInAsync(email, pwd, false, lockoutOnFailure : true); string role = ""; if (!result.Succeeded) { // JRaw res = (JRaw)("{'result':'error', 'message':'Invalid email or password'}"); var model = new { StatusCode = 404, result = "error", message = "Invalid email or password" }; /*return new JsonResult(model) * { * StatusCode = 404 // Status code here * * };*/ return(NotFound(model)); } else { // await _signInManager.SignInAsync(newUser, isPersistent: false); IdentityUser user = await _userManager.FindByEmailAsync(email); if (_userManager.IsInRoleAsync(user, "User").Result) { role = "User"; } else if (_userManager.IsInRoleAsync(user, "Admin").Result) { role = "Admin"; } if (_context.User.Where(a => a.Email == user.Email).Count() > 0) { var uu = _context.User.Where(a => a.Email == user.Email).FirstOrDefault(); var model = new { StatusCode = 200, result = "success", message = "profile found", profile = new { uId = user.Id, uEmail = user.Email, uPhoneNumber = uu.Phone, uP = uu.Address, uCreditcard = uu.Creditcard, uCreditcardName = uu.CreditcardName, uFirstName = uu.FirstName, uMiddleName = uu.MiddleName, uLastName = uu.LastName, uUserName = uu.UserName, Role = role } }; // return Ok(result.Succeeded); // return res; return(Ok(model)); } else { var model = new { StatusCode = 200, result = "success", message = "profile found", profile = new { uId = user.Id, uEmail = user.Email, uPhoneNumber = user.PhoneNumber, Role = role } }; // return Ok(result.Succeeded); // return res; return(Ok(model)); } // JRaw res= (JRaw)("{'result':'success', 'message':'profile found', 'profile':{'uId':'"+user.Id+ "', 'uEmail':'" + user.Email+ "', 'uFirstName':'" + user.first_name //+ "', 'uMiddleName':'" + user.middle_name + "', 'uLastName':'" + user.last_name+ "', 'uPhoneNumber':'" + user.PhoneNumber + "', 'Role':'" + role+ "' } }"); } }
/// <summary> /// A simple function that POST request to store messages in s3 /// </summary> /// <param name="input"></param> /// <param name="context"></param> /// <returns></returns> public string FunctionHandler(JRaw input, ILambdaContext context) { Console.WriteLine(input.ToString()); string response = ""; try { JToken jobj = JContainer.Parse(input.ToString()); // this is not working // string bucket = Environment.GetEnvironmentVariable("bucketname"); if (jobj != null) { Console.WriteLine(input.Value); MessageJSONProp e = jobj.ToObject <MessageJSONProp>(); Console.WriteLine(jobj.Value <string>("emp_name")); if (e != null) { Console.WriteLine(e.emp_doj); if (!Validate(e.emp_department.ToLower(), 'd') || !Validate(e.emp_type.ToLower(), 't') || !HasValidDOB(e.emp_dob)) { response += "invalid department (or) DOB (or) Employee type. "; } else { string mesFile = @"MessageFile_" + e.emp_id + ".json"; CustomS3AccessPoint.UploadMessage(mesFile, input.ToString()); response += "Employee data sent to bucket. "; } } else { response += "The JSON object is incomplete. "; } } }catch (Exception ex) { response += "Exception occured : " + ex.Message + ". "; } //Test JSON data : //{ // "emp_id": 1234, // "emp_name": "John" // "emp_type": "Fulltime", // "emp_dob": "12-10-1990", // "emp_doj": "10-01-2001", // "emp_department": "Finance" // } // string s = (string)details["emp_name"]; return(response); }
public EventData ToData() { return(new EventData(Type, Metadata, Payload.ToString())); }