Beispiel #1
0
        public void AddData(ModelNotifiedForShippers modelNotifiedForShippers, out string error)
        {
            ShippersGenericREST ShippersGenericREST = new ShippersGenericREST(wpfConfig);
            CreateShippersView  createShippersView  = new CreateShippersView();

            Cloner.CopyAllTo(typeof(ModelNotifiedForShippers), modelNotifiedForShippers, typeof(CreateShippersView), createShippersView);
            ShippersGenericREST.Insert(createShippersView, out error);
        }
Beispiel #2
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;

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

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

                resultContainer.ReportPostHeader.Message = "Success";
                HttpResponseMessage httpResponseMessage = new HttpResponseMessage();
                httpResponseMessage.StatusCode = System.Net.HttpStatusCode.Created;
                CreatedResult createdResult = new CreatedResult("Shippers/Create", httpResponseMessage);
                createdResult.Value = resultContainer;
                return(createdResult);
            }
            catch (Exception ex)
            {
                CreatedResult errorResult = helperRestError.GetError500_InternalServerError(transactionID, ex.Message, "x", "Shippers/Create");
                return(errorResult);
            }
        }
Beispiel #3
0
        public void TryInclude(CreateShippersView viewToInclude, out RestExceptionError error)
        {
            error = null;
            ShippersInfo dbViewToInclude = new ShippersInfo();

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

            try
            {
                ShippersBsn bsn     = new ShippersBsn(restConfig);
                string      dbError = null;
                bsn.InsertOne(dbViewToInclude, out dbError);
                if (dbError != null)
                {
                    error = new RestExceptionError();
                    error.InternalMessage  = "Internal Error Save data for [Shippers.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 [Shippers.TryInclude/Save]";
                error.ExceptionMessage = ex.Message;
                error.SourceError      = RestExceptionError._SourceError.ServerSide;
                error.StackTrace       = ex.StackTrace;
            }
        }