Exemplo n.º 1
0
        //ADD, UPDATE, DELETE Venues
        public int Add(VenueAddRequest request, int userId)
        {
            int    id       = 0;
            string procName = "[dbo].[Venues_Insert]";

            _data.ExecuteNonQuery(procName, inputParamMapper : delegate(SqlParameterCollection collection)
            {
                collection.AddWithValue("@Name", request.Name);
                collection.AddWithValue("@Description", request.Description);
                collection.AddWithValue("@LocationId", request.LocationId);
                collection.AddWithValue("@Url", request.Url);
                collection.AddWithValue("@CreatedBy", userId);
                collection.AddWithValue("@ModifiedBy", userId);

                SqlParameter idOut = new SqlParameter("@Id", SqlDbType.Int);
                idOut.Direction    = ParameterDirection.Output;
                collection.Add(idOut);
            }, returnParameters : delegate(SqlParameterCollection returnCollection)
            {
                object oId = returnCollection["@Id"].Value;
                int.TryParse(oId.ToString(), out id);
            });

            return(id);
        }
Exemplo n.º 2
0
        public int Insert(VenueAddRequest model, int userId)
        {
            int retVal = 0;

            _dataProvider.ExecuteNonQuery("dbo.Venues_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("@Name", model.Name);
                parms.AddWithValue("@Description", model.Description);
                parms.AddWithValue("@LocationId", model.LocationId);
                parms.AddWithValue("@Url", model.Url);
                parms.AddWithValue("@AvatarUrl", model.AvatarUrl);
                parms.AddWithValue("@CreatedBy", userId);  
                parms.AddWithValue("@ModifiedBy", userId);
            }, returnParameters: delegate (SqlParameterCollection parms)
            {
                Int32.TryParse(parms["@Id"].Value.ToString(), out retVal);
            });

            return retVal;
        }
Exemplo n.º 3
0
 public ActionResult <ItemResponse <int> > Insert(VenueAddRequest model)
 {
     try
     {
         ItemResponse <int> resp = new ItemResponse <int>();
         resp.Item = _venuesService.Insert(model, _authenticationService.GetCurrentUserId());
         return(Created201(resp));
     }
     catch (Exception ex)
     {
         Logger.LogError(ex.ToString());
         return(StatusCode(500, new ErrorResponse(ex.Message)));
     }
 }
        public ActionResult <ItemResponse <int> > Add(VenueAddRequest model)
        {
            int          code     = 200;
            BaseResponse response = null;

            try
            {
                int userId = _authService.GetCurrentUserId();
                int id     = _service.Add(model, userId);
                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));
        }