SHARE
TWEET

Untitled

a guest Jun 26th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. modelBuilder.Entity("Namespace.Models.PageContent", b =>
  2.                 {
  3.                     b.Property<int>("IdPageContent")
  4.                         .ValueGeneratedOnAdd()
  5.                         .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
  6.                 });
  7.      
  8. [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
  9.      
  10. private async Task UpdateCustomerPageContent(UpdateCustomerPageContentCommand request, CancellationToken cancellationToken)
  11.         {
  12.             var customerPage = await _unitOfWork.CustomerPages.FindById(request.CustomerPageId);
  13.             var content =
  14.                 customerPage.PageContent.FirstOrDefault(x => x.IdOrganization.Equals(request.CustomerOrganizationId));
  15.             var settings =
  16.                 customerPage.CustomerPageSettings.First(x => x.IdOrganization.Equals(request.CustomerOrganizationId));
  17.             settings.UseDefaultContent = false;
  18.             if (content == null)
  19.             {
  20.                 content = new Domain.PageContent();
  21.                 content.IdOrganization = request.CustomerOrganizationId;
  22.                 content.LastUpdatedBy = "noname"; //TODO: Getfrom UPN Claim
  23.                 content.CustomerPage = customerPage;
  24.             }
  25.  
  26.             content.HtmlContent = request.HtmlString;
  27.             await _unitOfWork.PageContent.InsertOrUpdate(content, cancellationToken);
  28.             await _unitOfWork.SaveChangesAsync(cancellationToken);
  29.         }
  30.      
  31. public async Task InsertOrUpdate(Domain.PageContent pageContent, CancellationToken cancellationToken = default)
  32.         {
  33.             var entity = _mapper.Map<Models.PageContent>(pageContent);
  34.             if (pageContent.IdPageContent == default)
  35.             {
  36.                 await _context.PageContent.AddAsync(entity, cancellationToken);
  37.             }
  38.             else
  39.             {
  40.                 _context.Entry(entity).State = EntityState.Modified;
  41.             }
  42.         }
  43.      
  44. public class PageContent
  45.     {
  46.         public int IdPageContent { get; set; }
  47.         public long IdOrganization { get; set; }
  48.         public string HtmlContent { get; set; }
  49.         public string LastUpdatedBy { get; set; }
  50.         public DateTime CreatedDate { get; set; }
  51.         public DateTime UpdatedDate { get; set; }
  52.  
  53.         public CustomerPage CustomerPage { get; set; }
  54.     }
  55.      
  56. public PageContentProfile()
  57.         {
  58.             CreateMap<Models.PageContent, Domain.PageContent>();
  59.             CreateMap<Domain.PageContent, Models.PageContent>();
  60.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top