public ResponseBase Update(OrderInfo Order) { ResponseBase response = new ResponseBase(); try { using (var ctx = new SimpleCureEntities()) { ctx.Entry(Order).State = EntityState.Modified; var updated = ctx.SaveChanges(); if (updated > 0) { response.ResponseSuccess = true; response.ResponseInt = Order.ID; } else { response.ResponseMessage = "Unable to update Order Info for Order: " + Order; } } } catch (Exception ex) { string obj = JsonConvert.SerializeObject(Order); string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name; string source = ex.Source; string stacktrace = ex.StackTrace; string targetsite = ex.TargetSite.ToString(); string error = ex.InnerException.ToString(); string ErrorMessage = $"There was an error at {DateTime.Now} {Environment.NewLine} Method: {methodName} {Environment.NewLine} Source: {source} {Environment.NewLine} StackTrace: {stacktrace} {Environment.NewLine} TargetSite: {targetsite} {Environment.NewLine} Error: {error}{Environment.NewLine} Object: {obj}"; _applicationError.Log(ErrorMessage, string.Empty); response.ResponseMessage = "Unable to update Order Info for Order: " + Order; } return(response); }
public ResponseBase Delete(OrderInfo_Product Product) { ResponseBase response = new ResponseBase(); try { using (var ctx = new SimpleCureEntities()) { ctx.OrderInfo_Product.Remove(Product); var Deleted = ctx.SaveChanges(); if (Deleted > 0) { response.ResponseSuccess = true; } else { response.ResponseMessage = "Unable to Delete Product Order with ID " + Product.ID; } } } catch (Exception ex) { string obj = JsonConvert.SerializeObject(Product); string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name; string source = ex.Source; string stacktrace = ex.StackTrace; string targetsite = ex.TargetSite.ToString(); string error = ex.InnerException.ToString(); string ErrorMessage = $"There was an error at {DateTime.Now} {Environment.NewLine} Method: {methodName} {Environment.NewLine} Source: {source} {Environment.NewLine} StackTrace: {stacktrace} {Environment.NewLine} TargetSite: {targetsite} {Environment.NewLine} Error: {error}{Environment.NewLine} Object: {obj}"; _applicationError.Log(ErrorMessage, string.Empty); response.ResponseMessage = "Unable to Delete Product Order with ID " + Product.ID; } return(response); }