public void SaveData(ModelNotifiedForTag modelNotifiedForTag, out string error) { TagGenericREST TagGenericREST = new TagGenericREST(wpfConfig); UpdateTagView updateTagView = new UpdateTagView(); Cloner.CopyAllTo(typeof(ModelNotifiedForTag), modelNotifiedForTag, typeof(UpdateTagView), updateTagView); TagGenericREST.Update(updateTagView, out error); }
public void TryUpdate(UpdateTagView viewToUpdate, out RestExceptionError error) { error = null; TagInfo dbViewToInclude = new TagInfo(); try { Cloner.CopyAllTo(typeof(UpdateTagView), viewToUpdate, typeof(TagInfo), dbViewToInclude); } catch (Exception ex) { error = new RestExceptionError(); error.InternalMessage = "Internal Error parsing data for (Tag.TryUpdate/Parsing)"; error.ExceptionMessage = ex.Message; error.SourceError = RestExceptionError._SourceError.ServerSide; error.StackTrace = ex.StackTrace; } try { TagBsn bsn = new TagBsn(restConfig); string dbError = null; bsn.UpdateOne(dbViewToInclude, out dbError); if (dbError != null) { error = new RestExceptionError(); error.InternalMessage = "Internal Error Save data for [Tag.TryUpdate]"; error.ExceptionMessage = dbError; error.SourceError = RestExceptionError._SourceError.ServerSide; error.StackTrace = ""; } } catch (Exception ex) { error = new RestExceptionError(); error.InternalMessage = "Internal Error Update data for [Tag.TryUpdate]"; error.ExceptionMessage = ex.Message; error.SourceError = RestExceptionError._SourceError.ServerSide; error.StackTrace = ex.StackTrace; } }
public IActionResult Update(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); UpdateTagView viewToInclude = rESTTagDB.TryParse <UpdateTagView>(GeneralBodyPost, out restExceptionError); if (restExceptionError != null) { CreatedResult errorResult = helperRestError.GetError412_PreConditionFailed(transactionID, restExceptionError.ExceptionMessage, restExceptionError.InternalMessage, "Tag/Insert"); return(errorResult); } rESTTagDB.TryUpdate(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.OK; CreatedResult createdResult = new CreatedResult("Tag/Update", httpResponseMessage); createdResult.Value = resultContainer; return(createdResult); } catch (Exception ex) { CreatedResult errorResult = helperRestError.GetError500_InternalServerError(transactionID, ex.Message, "x", "Tag/Create"); return(errorResult); } }