private CustomerDefaultModel mapToModel(CustomerDefault item) { var newItem = Mapper.Map <CustomerDefault, CustomerDefaultModel>(item); if (item.Country != null) { newItem.CountryNameText = item.Country.CountryName; } if (item.Currency != null) { newItem.CurrencyCodeText = item.Currency.CurrencyCode; } if (item.LOVItem_CustomerType != null) { newItem.CustomerTypeText = item.LOVItem_CustomerType.ItemText; } if (item.User_SalesPerson != null) { newItem.SalesPersonText = (item.User_SalesPerson.FirstName + " " + item.User_SalesPerson.LastName).Trim(); } if (item.PaymentTerm != null) { newItem.PaymentTermsText = item.PaymentTerm.TermsOfPaymentId; } if (item.TaxCode != null) { newItem.TaxCodeText = item.TaxCode.TaxCode1; } if (item.TaxCode_IfNoTaxId != null) { newItem.TaxCodeWithoutTaxIdText = item.TaxCode_IfNoTaxId.TaxCode1; } return(newItem); }
public Error InsertOrUpdateCustomerDefault(CustomerDefaultModel defaults, string lockGuid = "") { var error = validateCustomerDefaultModel(defaults); if (!error.IsError) { // Check that the lock is still current if (!db.IsLockStillValid(typeof(CustomerDefault).ToString(), defaults.Id, lockGuid)) { error.SetError(EvolutionResources.errRecordChangedByAnotherUser, "Name"); } else { CustomerDefault temp = null; if (defaults.Id != 0) { temp = db.FindCustomerDefault(defaults.Id); } if (temp == null) { temp = new CustomerDefault(); } mapToEntity(defaults, temp); if (temp.CountryId == 0) { temp.CountryId = null; } if (temp.PriceLevelId == 0) { temp.PriceLevelId = null; } if (temp.SalespersonId == 0) { temp.SalespersonId = null; } if (temp.CustomerTypeId == 0) { temp.CustomerTypeId = null; } if (temp.TaxCodeId == 0) { temp.TaxCodeId = null; } if (temp.TaxCodeWithoutTaxId == 0) { temp.TaxCodeWithoutTaxId = null; } db.InsertOrUpdateCustomerDefault(temp); defaults.Id = temp.Id; } } return(error); }
private void mapToEntity(CustomerDefaultModel model, CustomerDefault entity) { Mapper.Map <CustomerDefaultModel, CustomerDefault>(model, entity); }