public void SaveData(ModelNotifiedForSuppliers modelNotifiedForSuppliers, out string error) { SuppliersGenericREST SuppliersGenericREST = new SuppliersGenericREST(wpfConfig); UpdateSuppliersView updateSuppliersView = new UpdateSuppliersView(); Cloner.CopyAllTo(typeof(ModelNotifiedForSuppliers), modelNotifiedForSuppliers, typeof(UpdateSuppliersView), updateSuppliersView); SuppliersGenericREST.Update(updateSuppliersView, out error); }
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; RESTSuppliersDB rESTSuppliersDB = new RESTSuppliersDB(base.RESTConfig); UpdateSuppliersView viewToInclude = rESTSuppliersDB.TryParse <UpdateSuppliersView>(GeneralBodyPost, out restExceptionError); if (restExceptionError != null) { CreatedResult errorResult = helperRestError.GetError412_PreConditionFailed(transactionID, restExceptionError.ExceptionMessage, restExceptionError.InternalMessage, "Suppliers/Insert"); return(errorResult); } rESTSuppliersDB.TryUpdate(viewToInclude, out restExceptionError); if (restExceptionError != null) { CreatedResult errorResult = helperRestError.GetError500_InternalServerError(transactionID, restExceptionError.ExceptionMessage, restExceptionError.InternalMessage, "Suppliers/GetAll"); return(errorResult); } resultContainer.ReportPostHeader.Message = "Success"; HttpResponseMessage httpResponseMessage = new HttpResponseMessage(); httpResponseMessage.StatusCode = System.Net.HttpStatusCode.OK; CreatedResult createdResult = new CreatedResult("Suppliers/Update", httpResponseMessage); createdResult.Value = resultContainer; return(createdResult); } catch (Exception ex) { CreatedResult errorResult = helperRestError.GetError500_InternalServerError(transactionID, ex.Message, "x", "Suppliers/Create"); return(errorResult); } }
public void TryUpdate(UpdateSuppliersView viewToUpdate, out RestExceptionError error) { error = null; SuppliersInfo dbViewToInclude = new SuppliersInfo(); try { Cloner.CopyAllTo(typeof(UpdateSuppliersView), viewToUpdate, typeof(SuppliersInfo), dbViewToInclude); } catch (Exception ex) { error = new RestExceptionError(); error.InternalMessage = "Internal Error parsing data for (Suppliers.TryUpdate/Parsing)"; error.ExceptionMessage = ex.Message; error.SourceError = RestExceptionError._SourceError.ServerSide; error.StackTrace = ex.StackTrace; } try { SuppliersBsn bsn = new SuppliersBsn(restConfig); string dbError = null; bsn.UpdateOne(dbViewToInclude, out dbError); if (dbError != null) { error = new RestExceptionError(); error.InternalMessage = "Internal Error Save data for [Suppliers.TryUpdate]"; error.ExceptionMessage = dbError; error.SourceError = RestExceptionError._SourceError.ServerSide; error.StackTrace = ""; } } catch (Exception ex) { error = new RestExceptionError(); error.InternalMessage = "Internal Error Update data for [Suppliers.TryUpdate]"; error.ExceptionMessage = ex.Message; error.SourceError = RestExceptionError._SourceError.ServerSide; error.StackTrace = ex.StackTrace; } }