public void AddData(ModelNotifiedForCustomerDemographics modelNotifiedForCustomerDemographics, out string error) { CustomerDemographicsGenericREST CustomerDemographicsGenericREST = new CustomerDemographicsGenericREST(wpfConfig); CreateCustomerDemographicsView createCustomerDemographicsView = new CreateCustomerDemographicsView(); Cloner.CopyAllTo(typeof(ModelNotifiedForCustomerDemographics), modelNotifiedForCustomerDemographics, typeof(CreateCustomerDemographicsView), createCustomerDemographicsView); CustomerDemographicsGenericREST.Insert(createCustomerDemographicsView, out error); }
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; RESTCustomerDemographicsDB rESTCustomerDemographicsDB = new RESTCustomerDemographicsDB(base.RESTConfig); CreateCustomerDemographicsView viewToInclude = rESTCustomerDemographicsDB.TryParse <CreateCustomerDemographicsView>(GeneralBodyPost, out restExceptionError); if (restExceptionError != null) { CreatedResult errorResult = helperRestError.GetError412_PreConditionFailed(transactionID, restExceptionError.ExceptionMessage, restExceptionError.InternalMessage, "CustomerDemographics/Insert"); return(errorResult); } rESTCustomerDemographicsDB.TryInclude(viewToInclude, out restExceptionError); if (restExceptionError != null) { CreatedResult errorResult = helperRestError.GetError500_InternalServerError(transactionID, restExceptionError.ExceptionMessage, restExceptionError.InternalMessage, "CustomerDemographics/GetAll"); return(errorResult); } resultContainer.ReportPostHeader.Message = "Success"; HttpResponseMessage httpResponseMessage = new HttpResponseMessage(); httpResponseMessage.StatusCode = System.Net.HttpStatusCode.Created; CreatedResult createdResult = new CreatedResult("CustomerDemographics/Create", httpResponseMessage); createdResult.Value = resultContainer; return(createdResult); } catch (Exception ex) { CreatedResult errorResult = helperRestError.GetError500_InternalServerError(transactionID, ex.Message, "x", "CustomerDemographics/Create"); return(errorResult); } }
public void TryInclude(CreateCustomerDemographicsView viewToInclude, out RestExceptionError error) { error = null; CustomerDemographicsInfo dbViewToInclude = new CustomerDemographicsInfo(); try { Cloner.CopyAllTo(typeof(CreateCustomerDemographicsView), viewToInclude, typeof(CustomerDemographicsInfo), dbViewToInclude); } catch (Exception ex) { error = new RestExceptionError(); error.InternalMessage = "Internal Error parsing data for (CustomerDemographics.TryInclude/Parsing)"; error.ExceptionMessage = ex.Message; error.SourceError = RestExceptionError._SourceError.ServerSide; error.StackTrace = ex.StackTrace; } try { CustomerDemographicsBsn bsn = new CustomerDemographicsBsn(restConfig); string dbError = null; bsn.InsertOne(dbViewToInclude, out dbError); if (dbError != null) { error = new RestExceptionError(); error.InternalMessage = "Internal Error Save data for [CustomerDemographics.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 [CustomerDemographics.TryInclude/Save]"; error.ExceptionMessage = ex.Message; error.SourceError = RestExceptionError._SourceError.ServerSide; error.StackTrace = ex.StackTrace; } }