public CustomerInfoCreateOrEditOutput GetCustomerInfoForCreateOrEdit(CustomerInfoCreateOrEditInput input) { CustomerInfoCreateOrEditOutput customerInfo; if (input.Id.HasValue) { customerInfo = Repository.Get(input.Id.Value).MapTo <CustomerInfoCreateOrEditOutput>(); } else { customerInfo = new CustomerInfoCreateOrEditOutput(); } return(customerInfo); }
public CustomerInfoDto CreateOrEdit(CustomerInfoCreateOrEditInput input) { if (input.Id.HasValue) { CheckUpdatePermission(); var entity = GetEntityById(input.Id.Value); ObjectMapper.Map(input, entity); CustomerInfo defaultCustomerInfo = CustomerInfoManager.GetDefaultCustomerInfo(InfrastructureSession.UserId.Value); if (defaultCustomerInfo == null) { entity.IsDefault = true; } CurrentUnitOfWork.SaveChanges(); return(MapToEntityDto(entity)); } else { CheckCreatePermission(); var entity = input.MapTo <CustomerInfo>(); CustomerInfo defaultCustomerInfo = CustomerInfoManager.GetDefaultCustomerInfo(InfrastructureSession.UserId.Value); if (defaultCustomerInfo == null) { entity.IsDefault = true; } Repository.Insert(entity); CurrentUnitOfWork.SaveChanges(); return(MapToEntityDto(entity)); } }