public Error InsertOrUpdateCustomerFreight(CustomerFreightModel freight, UserModel user, string lockGuid) { var error = validateCustomerFreightModel(freight); if (!error.IsError) { // Check that the lock is still current if (!db.IsLockStillValid(typeof(Customer).ToString(), freight.CustomerId, lockGuid)) { error.SetError(EvolutionResources.errRecordChangedByAnotherUser, "ContactFirstname"); } else { Customer temp = null; if (freight.CustomerId != 0) { temp = db.FindCustomer(freight.CustomerId); if (temp != null) { MapToEntity(freight, temp); db.InsertOrUpdateCustomer(temp); } } } } return(error); }
public CustomerFreightModel FindCustomerFreightModel(int customerId, CompanyModel company) { CustomerFreightModel model = new CustomerFreightModel { CompanyId = company.Id, CustomerId = customerId }; var c = db.FindCustomer(customerId); if (c != null) { model = MapToCustomerFreightModel(c); model.CustomerId = c.Id; } return(model); }
private Error validateCustomerFreightModel(CustomerFreightModel model) { var error = isValidNonRequiredString(getFieldValue(model.DeliveryInstructions), 255, "DeliveryInstructions", EvolutionResources.errTextDataRequiredInField); if (!error.IsError) { error = isValidNonRequiredString(getFieldValue(model.DeliveryContact), 30, "DeliveryInstructions", EvolutionResources.errTextDataRequiredInField); } if (!error.IsError) { error = isValidNonRequiredString(getFieldValue(model.ShipMethodAccount), 20, "ShipMethodAccount", EvolutionResources.errTextDataRequiredInField); } if (!error.IsError) { error = isValidNonRequiredString(getFieldValue(model.WarehouseInstructions), 100, "WarehouseInstructions", EvolutionResources.errTextDataRequiredInField); } return(error); }
public string LockCustomerFreight(CustomerFreightModel model) { return(db.LockRecord(typeof(Customer).ToString(), model.CustomerId)); }
public void MapToEntity(CustomerFreightModel model, Customer entity) { Mapper.Map <CustomerFreightModel, Customer>(model, entity); }