Exemplo n.º 1
0
 public IHttpActionResult Post(EventTypeAddRequest model)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         ItemResponse <int> response = new ItemResponse <int>
         {
             Item = _eventTypeService.Post(model)
         };
         return(Ok(response));
     }
     catch (Exception ex)
     {
         _errorLogService.Post(new Models.Requests.Logs.ErrorLogAddRequest
         {
             ErrorSourceTypeId = 1,
             Message           = ex.Message,
             StackTrace        = ex.StackTrace,
             Title             = "Error in " + GetType().Name + " " + System.Reflection.MethodBase.GetCurrentMethod().Name
         });
         return(BadRequest(ex.Message));
     }
 }
Exemplo n.º 2
0
        public IHttpActionResult Post(EventTypeAddRequest model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                ItemResponse <int> response = new ItemResponse <int>
                {
                    Item = _eventTypeService.Insert(model)
                };
                return(Ok(response));
            }
            catch (Exception ex)
            {
                int currentUser = _userService.GetCurrentUserId();
                _appLogService.Insert(new AppLogAddRequest
                {
                    AppLogTypeId = 1,
                    Message      = ex.Message,
                    StackTrace   = ex.StackTrace,
                    Title        = "Error in " + GetType().Name + " " + System.Reflection.MethodBase.GetCurrentMethod().Name,
                    UserBaseId   = currentUser
                });

                return(BadRequest(ex.Message));
            }
        }
Exemplo n.º 3
0
        //Insert new Event Type
        public int Post(EventTypeAddRequest model)
        {
            int id = 0;

            DataProvider.ExecuteNonQuery("dbo.Events_EventType_Insert",
                                         inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@TypeName", model.TypeName);
                paramCollection.AddWithValue("@TypeDescription", model.TypeDescription);

                SqlParameter paramId = new SqlParameter("@Id", SqlDbType.Int);
                paramId.Direction    = ParameterDirection.Output;
                paramId.Value        = id;
                paramCollection.Add(paramId);
            },
                                         returnParameters : delegate(SqlParameterCollection paramCollection)
            {
                int.TryParse(paramCollection["@Id"].Value.ToString(), out id);
            });
            return(id);
        }
        public int Insert(EventTypeAddRequest model)
        {
            int returnValue = 0;

            DataProvider.ExecuteNonQuery("dbo.EventType_Insert",
                                         inputParamMapper: (SqlParameterCollection inputs) =>
            {
                inputs.AddWithValue("@TypeName", model.TypeName);
                inputs.AddWithValue("@TypeDescription", model.TypeDescription);

                SqlParameter idOut = new SqlParameter("@Id", 0);
                idOut.Direction    = ParameterDirection.Output;
                inputs.Add(idOut);
            },
                                         returnParameters: (SqlParameterCollection inputs) =>
            {
                int.TryParse(inputs["@Id"].Value.ToString(), out returnValue);
            });

            return(returnValue);
        }