예제 #1
0
        public ActionResult <ItemResponse <int> > Created(CrowdAddRequest model)
        {
            ObjectResult result = null;

            try
            {
                int   id     = _service.Add(model);
                Crowd _crowd = _service.GetBySpotId(model.SpotId);
                ItemResponse <Crowd> response = new ItemResponse <Crowd> {
                    Item = _crowd
                };
                result = Created201(response);
            }
            catch (Exception ex)
            {
                base.Logger.LogError(ex.ToString());
                ErrorResponse response = new ErrorResponse(ex.Message);

                result = StatusCode(500, response);
            }
            return(result);
        }
예제 #2
0
        public int Add(CrowdAddRequest model)
        {
            int id = 0;

            string procName = "[dbo].[Crowds_Insert]";

            _data.ExecuteNonQuery(procName,
                                  inputParamMapper : delegate(SqlParameterCollection col)
            {
                col.AddWithValue("@SpotId", model.SpotId);
                col.AddWithValue("@CrowdedLevelId", model.CrowdedLevelId);

                SqlParameter idOut = new SqlParameter("@Id", SqlDbType.Int);
                idOut.Direction    = ParameterDirection.Output;

                col.Add(idOut);
            }, returnParameters : delegate(SqlParameterCollection returnCollection)
            {
                object oId = returnCollection["@Id"].Value;
                int.TryParse(oId.ToString(), out id);
            });
            return(id);
        }