Ejemplo n.º 1
0
 public void Configure(EntityTypeBuilder <Advertisment> builder)
 {
     builder.Property(c => c.Price).HasConversion(c => c.Value.Value, d => Price.FromLong(d));
     builder.Property(c => c.OwnerId).HasConversion(c => c.Value.ToString(), d => UserId.FromString(d));
     builder.Property(c => c.ApprovedBy).HasConversion(c => c.Value.ToString(), d => UserId.FromString(d));
     builder.Property(c => c.Text).HasConversion(c => c.Value, d => AdvertismentText.FromString(d));
     builder.Property(c => c.Title).HasConversion(c => c.Value, d => AdvertismentTitle.FromString(d));
 }
Ejemplo n.º 2
0
        public void Handle(SetTitle command)
        {
            var advertisement = advertisementsRepository.Load(command.Id);

            if (advertisement == null)
            {
                throw new InvalidOperationException($"آگهی با شناسه {command.Id} یافت نشد.");
            }
            advertisement.SetTitle(AdvertismentTitle.FromString(command.Title));
            unitOfWork.Commit();
        }