public OperationResponse Insert(ProductColorType entity) { var result = new OperationResponse(); try { var dbLocator = AmbientDbContextLocator.Get <RiverdaleDBContext>(); dbLocator.Add(entity); } catch (Exception ex) { result.AddException($"Error adding customer freightout", ex); } return(result); }
//public OperationResponse Update(ProductColorType input) //{ // var result = new OperationResponse<ProductColorTypeUpdateCommandOutputDTO>(); // try // { // var dbLocator = AmbientDbContextLocator.Get<RiverdaleDBContext>(); // { // var entity = dbLocator.Set<ProductColorType>().FirstOrDefault(o => o.Id == input.Id); // if (entity != null) // { // } // } // } // catch (Exception ex) // { // result.AddException($"Error updating customer freightout", ex); // } // return result; //} public OperationResponse Delete(ProductColorType entity) { var result = new OperationResponse(); var dbLocator = this.AmbientDbContextLocator.Get <RiverdaleDBContext>(); { try { dbLocator.Set <ProductColorType>().Remove(entity); } catch (Exception ex) { result.AddException("Error deleting Product Color Type", ex); } } return(null); }
public OperationResponse <ProductColorTypeDeleteCommandOutputDTO> LogicalDelete(ProductColorType entity) { var result = new OperationResponse <ProductColorTypeDeleteCommandOutputDTO>(); var dbLocator = this.AmbientDbContextLocator.Get <RiverdaleDBContext>(); { try { if (!(entity.IsDeleted ?? false)) { entity.DeletedAt = DateTime.UtcNow; dbLocator.SaveChanges(); } } catch (Exception ex) { result.AddException("Error voiding Product Color Type", ex); } } return(null); }