public bool InsertUserHobbiesDetails(UserHobbiesDetails details) { List <SqlParameter> sp = new List <SqlParameter>() { new SqlParameter() { ParameterName = "@user_id", Value = details.User_Id, SqlDbType = SqlDbType.BigInt }, new SqlParameter() { ParameterName = "@hobbiesid", Value = details.HobbiesId, SqlDbType = SqlDbType.BigInt }, }; object[] parameters = sp.ToArray(); var users = _hobbiesRepository.ExecuteStoredProcedureList <AuthUser>(PROC_INSERT_USER_HOBBIES, parameters); if (users != null) { return(true); } else { return(false); } }
public IHttpActionResult InsertUserHobbies(RequestModel model) { ReturnMsg obj = new ReturnMsg(); try { if (string.IsNullOrEmpty(model.Id)) { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.Forbidden, "User Id is required."))); } long userId = Convert.ToInt64(model.Id); ReturnMsg det = _hobbiesService.DeleteUserHobbiesByUserId(userId); if (string.IsNullOrEmpty(model.ScheduleId)) { } else { List <long> hobbiesList = new List <long>(); var sceduleIds = model.ScheduleId.Split(',').ToList(); foreach (var item in sceduleIds) { hobbiesList.Add(Convert.ToInt64(item)); } if (det.IsSuccess) { foreach (var item in hobbiesList) { UserHobbiesDetails details = new UserHobbiesDetails(); details.HobbiesId = item; details.User_Id = userId; _hobbiesService.InsertUserHobbiesDetails(details); } obj.IsSuccess = true; obj.Message = "User Hobbies is inserted successfully."; } } } catch (Exception e) { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e.Message))); } return(Ok(obj)); }