コード例 #1
0
        public bool InsertHobbiesDetails(HobbiesDetails details)
        {
            List <SqlParameter> sp = new List <SqlParameter>()
            {
                new SqlParameter()
                {
                    ParameterName = "@name", Value = details.Name, SqlDbType = SqlDbType.NChar
                },
            };

            object[] parameters = sp.ToArray();
            var      users      = _hobbiesRepository.ExecuteStoredProcedureList <AuthUser>(PROC_INSERT_HOBBIES, parameters);

            if (users != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        public IHttpActionResult InsertHobbies(RequestModel model)
        {
            ReturnMsg obj = new ReturnMsg();

            try
            {
                if (string.IsNullOrEmpty(model.Content))
                {
                    return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.Forbidden, "Name is required.")));
                }
                HobbiesDetails details = new HobbiesDetails();
                details.Name = model.Content;
                _hobbiesService.InsertHobbiesDetails(details);
                obj.IsSuccess = true;
                obj.Message   = "Hobbies Details inserted successfully.";
            }
            catch (Exception e)
            {
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e.Message)));
            }
            return(Ok(obj));
        }