Пример #1
0
        public void AddData(ModelNotifiedForTag modelNotifiedForTag, out string error)
        {
            TagGenericREST TagGenericREST = new TagGenericREST(wpfConfig);
            CreateTagView  createTagView  = new CreateTagView();

            Cloner.CopyAllTo(typeof(ModelNotifiedForTag), modelNotifiedForTag, typeof(CreateTagView), createTagView);
            TagGenericREST.Insert(createTagView, out error);
        }
Пример #2
0
        public void TryInclude(CreateTagView viewToInclude, out RestExceptionError error)
        {
            error = null;
            TagInfo dbViewToInclude = new TagInfo();

            try
            {
                Cloner.CopyAllTo(typeof(CreateTagView), viewToInclude, typeof(TagInfo), dbViewToInclude);
            }
            catch (Exception ex)
            {
                error = new RestExceptionError();
                error.InternalMessage  = "Internal Error parsing data for (Tag.TryInclude/Parsing)";
                error.ExceptionMessage = ex.Message;
                error.SourceError      = RestExceptionError._SourceError.ServerSide;
                error.StackTrace       = ex.StackTrace;
            }

            try
            {
                TagBsn bsn     = new TagBsn(restConfig);
                string dbError = null;
                bsn.InsertOne(dbViewToInclude, out dbError);
                if (dbError != null)
                {
                    error = new RestExceptionError();
                    error.InternalMessage  = "Internal Error Save data for [Tag.TryInclude/Save]";
                    error.ExceptionMessage = dbError;
                    error.SourceError      = RestExceptionError._SourceError.ServerSide;
                    error.StackTrace       = "";
                }
            }
            catch (Exception ex)
            {
                error = new RestExceptionError();
                error.InternalMessage  = "Internal Error Save data for [Tag.TryInclude/Save]";
                error.ExceptionMessage = ex.Message;
                error.SourceError      = RestExceptionError._SourceError.ServerSide;
                error.StackTrace       = ex.StackTrace;
            }
        }
Пример #3
0
        public IActionResult Create(GeneralBodyPost GeneralBodyPost)
        {
            string          transactionID   = Guid.NewGuid().ToString();
            string          currentURL      = this.Request.Method;
            HelperRestError helperRestError = new HelperRestError();
            HelperHTTPLog   helperHTTPLog   = new HelperHTTPLog(HelperHTTPLog.WhatToLog.All);

            try
            {
                GeneralPostResponse resultContainer = new GeneralPostResponse();
                resultContainer.ReportPostHeader.TransactionID = transactionID;
                RestExceptionError restExceptionError = null;

                RESTTagDB     rESTTagDB     = new RESTTagDB(base.RESTConfig);
                CreateTagView viewToInclude = rESTTagDB.TryParse <CreateTagView>(GeneralBodyPost, out restExceptionError);
                if (restExceptionError != null)
                {
                    CreatedResult errorResult = helperRestError.GetError412_PreConditionFailed(transactionID, restExceptionError.ExceptionMessage, restExceptionError.InternalMessage, "Tag/Insert");
                    return(errorResult);
                }

                rESTTagDB.TryInclude(viewToInclude, out restExceptionError);
                if (restExceptionError != null)
                {
                    CreatedResult errorResult = helperRestError.GetError500_InternalServerError(transactionID, restExceptionError.ExceptionMessage, restExceptionError.InternalMessage, "Tag/GetAll");
                    return(errorResult);
                }

                resultContainer.ReportPostHeader.Message = "Success";
                HttpResponseMessage httpResponseMessage = new HttpResponseMessage();
                httpResponseMessage.StatusCode = System.Net.HttpStatusCode.Created;
                CreatedResult createdResult = new CreatedResult("Tag/Create", httpResponseMessage);
                createdResult.Value = resultContainer;
                return(createdResult);
            }
            catch (Exception ex)
            {
                CreatedResult errorResult = helperRestError.GetError500_InternalServerError(transactionID, ex.Message, "x", "Tag/Create");
                return(errorResult);
            }
        }