コード例 #1
0
        public int Add(ProviderLicenseAddRequest model, int userId)
        {
            int id = 0;

            string procName = "dbo.Licenses_Insert";

            _data.ExecuteNonQuery(procName, inputParamMapper : delegate(SqlParameterCollection col)
            {
                SqlParameter idOut = new SqlParameter("@Id", SqlDbType.Int);
                idOut.Direction    = ParameterDirection.Output;


                col.Add(idOut);

                col.AddWithValue("@LicenseStateId", model.LicenseStateId);
                col.AddWithValue("@LicenseNumber", model.LicenseNumber);
                col.AddWithValue("@DateExpires", model.DateExpires);
                col.AddWithValue("@CreatedBy", userId);
            }, returnParameters : delegate(SqlParameterCollection returnCol)
            {
                object outputId = returnCol["@Id"].Value;
                Int32.TryParse(outputId.ToString(), out id);
            });
            return(id);
        }
コード例 #2
0
        public ActionResult <ItemResponse <int> > Add(ProviderLicenseAddRequest 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);
        }