public static void AddCommonParams(UserProfileAddRequest model, SqlParameterCollection col) { col.AddWithValue("@FirstName", model.FirstName); col.AddWithValue("@LastName", model.LastName); col.AddWithValue("@Mi", model.MI); col.AddWithValue("@AvatarUrl", model.AvatarUrl); }
public int AddProfile(UserProfileAddRequest model, int userId) { int id = 0; _dataProvider.ExecuteNonQuery("dbo.UserProfiles_Insert", inputParamMapper : delegate(SqlParameterCollection parms) { SqlParameter parm = new SqlParameter(); parm.ParameterName = "@Id"; parm.SqlDbType = SqlDbType.Int; parm.Direction = ParameterDirection.Output; parms.Add(parm); parms.AddWithValue("@UserId", userId); parms.AddWithValue("@FirstName", model.FirstName); parms.AddWithValue("@LastName", model.LastName); parms.AddWithValue("@Bio", model.Bio ?? SqlString.Null); parms.AddWithValue("@AvatarUrl", model.AvatarUrl ?? SqlString.Null); parms.AddWithValue("@Phone", model.Phone); parms.AddWithValue("@RaceEthnicityId", model.RaceEthnicityId ?? SqlInt32.Null); parms.AddWithValue("@EducationLevelId", model.EducationLevelId ?? SqlInt32.Null); parms.AddWithValue("@HouseIncome", model.HouseIncome); parms.AddWithValue("@YearsInBusiness", model.YearsInBusiness ?? SqlInt32.Null); parms.AddWithValue("@Zip", model.Zip); }, returnParameters : delegate(SqlParameterCollection parms) { Int32.TryParse(parms["@Id"].Value.ToString(), out id); }); return(id); }
public int Add(UserProfileAddRequest model, int userId) { int id = 0; string procName = "[dbo].[UserProfile_Insert_V2]"; _data.ExecuteNonQuery(procName, inputParamMapper : delegate(SqlParameterCollection col) { col.AddWithValue("@GivenName", model.GivenName); col.AddWithValue("@Surnames", model.Surnames); col.AddWithValue("@AvatarUrl", model.AvatarUrl); col.AddWithValue("@UserId", userId); col.AddWithValue("@Url", model.Url); col.AddWithValue("@UrlTypeId", model.UrlTypeId); SqlParameter idOut = new SqlParameter("@ProfileId", SqlDbType.Int); idOut.Direction = ParameterDirection.Output; col.Add(idOut); }, returnParameters : delegate(SqlParameterCollection returnCollection) { object oId = returnCollection["@ProfileId"].Value; int.TryParse(oId.ToString(), out id); }); return(id); }
public int Add(UserProfileAddRequest model) { int id = 0; string procName = "[dbo].[UserProfiles_Insert]"; _data.ExecuteNonQuery(procName, inputParamMapper : delegate(SqlParameterCollection col) { CommonParams(model, col); SqlParameter idOut = new SqlParameter("@Id", SqlDbType.Int); idOut.Direction = ParameterDirection.Output; col.Add(idOut); }, returnParameters : delegate(SqlParameterCollection returnCol) { object oId = returnCol["@Id"].Value; int.TryParse(oId.ToString(), out id); }); return(id); }
private void UserProfileParamsCollection(UserProfileAddRequest model, SqlParameterCollection col) { col.AddWithValue("@FirstName", model.FirstName); col.AddWithValue("@LastName", model.LastName); col.AddWithValue("@Mi", model.Mi); col.AddWithValue("@AvatarUrl", model.AvatarUrl); }
public ActionResult Create(UserProfileAddRequest model) { ObjectResult result = null; try { int userId = _authService.GetCurrentUserId(); int id = _service.Add(model, userId); ItemResponse <int> response = new ItemResponse <int>() { Item = id }; result = Created201(response); } catch (Exception ex) { Logger.LogError(ex.ToString()); ErrorResponse response = new ErrorResponse(ex.Message); result = StatusCode(500, response); } return(result); }
private static void AddCommonParameters(UserProfileAddRequest model, SqlParameterCollection paramCol) { paramCol.AddWithValue("@FirstName", model.FirstName); paramCol.AddWithValue("@LastName", model.LastName); paramCol.AddWithValue("@Mi", model.Mi); paramCol.AddWithValue("@AvatarUrl", model.AvatarUrl); }
private static void PopulatesParamCol(UserProfileAddRequest model, SqlParameterCollection paramCol) { var nullVal = (object)DBNull.Value; paramCol.AddWithValue("@FirstName", model.FirstName); paramCol.AddWithValue("@LastName", model.LastName); paramCol.AddWithValue("@AvatarUrl", model.AvatarUrl ?? nullVal); paramCol.AddWithValue("@Description", model.Description ?? nullVal); paramCol.AddWithValue("@DOB", model.DOB ?? nullVal); paramCol.AddWithValue("@PhoneNumber", model.PhoneNumber ?? nullVal); }
public ActionResult <ItemResponse <int> > AddProfile(UserProfileAddRequest model) { try { int id = _profileService.AddProfile(model, _authService.GetCurrentUserId()); ItemResponse <int> resp = new ItemResponse <int>(); resp.Item = id; return(Created201(resp)); } catch (Exception ex) { Logger.LogError(ex.ToString()); return(StatusCode(500, new ErrorResponse(ex.Message))); } }
public ActionResult <ItemResponse <int> > Insert(UserProfileAddRequest model) { ActionResult result = null; try { int currentId = _authenticationService.GetCurrentUserId(); int id = _userProfile.Insert(model, currentId); ItemResponse <int> response = new ItemResponse <int>(); response.Item = id; result = Created201(response); } catch (Exception ex) { Logger.LogError(ex.ToString()); result = StatusCode(500, new ErrorResponse(ex.Message)); } return(result); }
public int Insert(UserProfileAddRequest model, int userId) { int newUserProfileId = 0; _dataProvider.ExecuteNonQuery( "dbo.UserProfiles_Insert", (parameters) => { if (model.AvatarUrl == null || model.AvatarUrl.ToString() == "") { parameters.AddWithValue("@AvatarUrl", ""); } else { parameters.AddWithValue("@AvatarUrl", model.AvatarUrl.ToString()); } parameters.AddWithValue("@FirstName", model.FirstName); parameters.AddWithValue("@LastName", model.LastName); parameters.AddWithValue("@Description", model.Description); // parameters.AddWithValue("@DOB", model.DOB); if (model.DOB == null || model.DOB.ToString() == "") { parameters.AddWithValue("@DOB", DBNull.Value); } else { parameters.AddWithValue("@DOB", model.DOB); } parameters.AddWithValue("@UserId", userId); parameters.AddWithValue("@PhoneNumber", model.PhoneNumber); parameters.AddWithValue("@MilestoneId", model.MilestoneId); parameters.Add("@Id", SqlDbType.Int).Direction = ParameterDirection.Output; }, (parameters) => { Int32.TryParse(parameters["@Id"].Value.ToString(), out newUserProfileId); } ); return(newUserProfileId); }
public int Insert(UserProfileAddRequest model, int currentId) { int id = 0; _dataProvider.ExecuteNonQuery("dbo.UserProfiles_Insert", inputParamMapper : delegate(SqlParameterCollection paramCol) { SqlParameter param = new SqlParameter(); param.ParameterName = "@Id"; param.SqlDbType = System.Data.SqlDbType.Int; param.Direction = System.Data.ParameterDirection.Output; paramCol.Add(param); PopulatesParamCol(model, paramCol); paramCol.AddWithValue("@UserId", currentId); }, returnParameters : delegate(SqlParameterCollection paramCol) { int.TryParse(paramCol["@Id"].Value.ToString(), out id); } ); return(id); }
public ActionResult <ItemResponse <int> > Add(UserProfileAddRequest model) { int code = 201; BaseResponse response = null; try { int userId = _authService.GetCurrentUserId(); int id = _service.Add(model); response = new ItemResponse <int> { Item = id }; } catch (Exception ex) { code = 500; response = new ErrorResponse(ex.Message); base.Logger.LogError(ex.ToString()); } return(StatusCode(code, response)); }
public ActionResult <ItemResponse <int> > Insert(UserProfileAddRequest model) { ItemResponse <int> response = null; ActionResult result = null; int userId = _authService.GetCurrentUserId(); try { int newId = _userProfileServices.Insert(model, userId); if (newId > 0) { response = new ItemResponse <int>(); response.Item = newId; result = Ok200(response); } else { result = NotFound404(new ErrorResponse("Please Check All Your Fields")); } } catch (Exception ex) { if (userId > 0) { result = Ok200(response); } else { Logger.LogError(ex.ToString()); result = StatusCode(500, new ErrorResponse(ex.Message)); } } return(result); }