예제 #1
0
        public virtual IGenericWebApiResult Post(T data)
        {
            try
            {
                using (var result = new GenericWebApiResult <T>())
                {
                    result.Data    = data;
                    result.Success = repo.Create(result.Data);
                    result.Message = result.Success ? BaseConstants.MESSAGE_CREATE_SUCCESS : BaseConstants.MESSAGE_INVALID_DATA;

                    return(result);
                }
            }
            catch (Exception ex)
            {
                using (var result = new GenericWebApiResult <T>(ex))
                {
                    result.Data    = data;
                    result.Success = false;

                    dynamic more = new ExpandoObject();
                    more.Errors = ex.Message;
                    result.More = more;

                    return(result);
                }
            }
        }