public static void UpdateProduct(NorthwindContext dbContext, int id, ProductDTO modifiedProduct) { try { Product dataBaseProduct = GetProductById(dbContext, id); modifiedProduct.ModifyDataBaseProduct(dataBaseProduct); dbContext.SaveChanges(); } catch (Exception ex) when(ExceptionTypes.IsSqlException(ex)) { ex.SetMessage(DbExceptionMessages.FailedToUpdate(InstanceName, id, ex.InnerException)); throw; } catch (Exception ex) when(ExceptionTypes.IsDbException(ex)) { ex.SetMessage(DbExceptionMessages.UnexpectedFailure(ex)); throw; } }
public static void UpdateCustomer(NorthwindContext dbContext, string id, CustomerDTO modifiedCustomer) { try { Customer dataBaseCustomer = GetCustomerById(dbContext, id); modifiedCustomer.ModifyDataBaseCustomer(dataBaseCustomer); dbContext.SaveChanges(); } catch (Exception ex) when(ExceptionTypes.IsSqlException(ex)) { ex.SetMessage(DbExceptionMessages.FailedToUpdate(InstanceName, id, ex.InnerException)); throw; } catch (Exception ex) when(ExceptionTypes.IsDbException(ex)) { ex.SetMessage(DbExceptionMessages.UnexpectedFailure(ex)); throw; } }
public static void UpdateEmployee(NorthwindContext dbContext, int id, EmployeeDTO modifiedEmployee) { try { Employee dataBaseEmployee = GetEmployeeById(dbContext, id); modifiedEmployee.ModifyDataBaseEmployee(dataBaseEmployee); dbContext.SaveChanges(); } catch (Exception ex) when(ExceptionTypes.IsSqlException(ex)) { ex.SetMessage(DbExceptionMessages.FailedToUpdate(InstanceName, id, ex.InnerException)); throw; } catch (Exception ex) when(ExceptionTypes.IsDbException(ex)) { ex.SetMessage(DbExceptionMessages.UnexpectedFailure(ex)); throw; } }