public static string Start(RequestType request, out bool HasResponse) { string result = ""; try { switch (request.FuncName) { case "Register": Register_Params Rpar = (Register_Params)JsonConvert.DeserializeObject(request.Params.ToString(), typeof(Register_Params)); result = Register(Rpar); break; case "UpdateUserInformation": UpdateUserInformation_Params UUIpar = (UpdateUserInformation_Params)JsonConvert.DeserializeObject(request.Params.ToString(), typeof(UpdateUserInformation_Params)); result = UpdateUserInformation(UUIpar); break; default: break; } } catch { result = "error in parameter format"; } HasResponse = true; return(result); }
private static string UpdateUserInformation(UpdateUserInformation_Params uuip) { string result = ""; ResponseType rt = new ResponseType(); SqlConnection cnn = new SqlConnection(Properties.Settings.Default.__connection); SqlCommand cmm = new SqlCommand(); cmm.Connection = cnn; try { cmm.CommandText = "UPDATE UserIdentifier SET TeamColor=@TeamColor,TeamTitle=@TeamTitle," + "Name=@Name,EmailAdress=@EmailAdress,Phonenumber=@Phonenumber" + " WHERE id=@id"; cmm.Parameters.AddWithValue("TeamColor", uuip.TeamColor); cmm.Parameters.AddWithValue("TeamTitle", uuip.TeamTitle); cmm.Parameters.AddWithValue("Name", uuip.Name); cmm.Parameters.AddWithValue("EmailAdress", uuip.EmailAdress); cmm.Parameters.AddWithValue("Phonenumber", uuip.PhoneNumber); cmm.Parameters.AddWithValue("id", uuip.ID); try { if (cnn.State != ConnectionState.Open) { cnn.Open(); } } catch { } int rowEffected = cmm.ExecuteNonQuery(); try { if (cnn.State != ConnectionState.Closed) { cnn.Close(); } } catch { } if (rowEffected > 0) { rt.state = true; rt.retVal = "done"; } else { rt.state = false; rt.retVal = "no user founded"; } } catch (Exception e) { rt.state = false; rt.retVal = e.Message; } try { result = JsonConvert.SerializeObject(rt, typeof(ResponseType), new JsonSerializerSettings()); } catch (Exception e) { result = "error : " + e.Message; } return(result); }