public string UpdateExperience(int experienceId = -1, string propertyId = null, string propertyValue = null , string token = null) { if (Request.RequestType.Equals("OPTIONS", StringComparison.InvariantCultureIgnoreCase)) { return null; } try { int authUserId = -1; if (token != null) { authUserId = authenticationEngine.authenticate(token); } else { return AddErrorHeader("An authentication token must be passed in", 2); } if (authUserId < 0) { return AddErrorHeader("You are not authenticated, please log in!", 2); } Experience exp = new Experience(); if (experienceId > 0) { exp = userManager.GetExperience(experienceId); } else { return AddErrorHeader("An experienceId must be passed in", 1); } if (exp.userId != authUserId) { return AddErrorHeader("User is not authorized to exit this experience", 3); } System.Reflection.PropertyInfo pi; if(propertyId == null) { return AddErrorHeader("A propertyId must be passed in", 1); } else { pi = exp.GetType().GetProperty(propertyId); } if(propertyValue == null) { return AddErrorHeader("A propertyValue must be passed in", 1); } else { if(propertyId == "startDate" || propertyId == "endDate") { pi.SetValue(exp, Convert.ChangeType(DateTime.Parse(propertyValue), pi.PropertyType), null); } else { pi.SetValue(exp, Convert.ChangeType(propertyValue, pi.PropertyType), null); } Experience exp1 = userManager.UpdateExperience(exp); JsonModels.Experience returnExp = userManager.GetExperienceJson(exp1.id); string ret = Serialize(returnExp); return AddSuccessHeader(ret); } } catch(Exception ex) { logAccessor.CreateLog(DateTime.Now, "userController - updateExperience", ex.StackTrace); return AddErrorHeader("Something went wrong while updating this experience element", 1); } }