Exemplo n.º 1
0
 public async Task<IActionResult> Create([Bind("Id,Price,Address,City,Zip,YearBuilt,PropertyType,SquareFeet,Bedrooms,Bathrooms,GarageCapacity,RelatorName,RelatorPhone,RelatorEmail")] Property @property)
 {
     if (ModelState.IsValid)
     {
         _context.Add(@property);
         await _context.SaveChangesAsync();
         return RedirectToAction(nameof(Index));
     }
     return View(@property);
 }
        public async Task <IActionResult> Update([FromBody] BedType bedType)
        {
            var tmp = await _propertyContext.BedTypes.SingleOrDefaultAsync(b => b.Id == bedType.Id);

            if (tmp == null)
            {
                return(NotFound(new { Message = $"Item with id {bedType.Id} not found." }));
            }
            _propertyContext.Update(bedType);
            await _propertyContext.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetItemById), new { id = bedType.Id }, null));
        }
Exemplo n.º 3
0
 public async Task SyncProperties()
 {
     await foreach (var batch in _source.GetProperties())
     {
         _context.AddRange(batch);
         await _context.SaveChangesAsync();
     }
 }
            public async Task <int> Handle(Command request, CancellationToken cancellationToken)
            {
                var pr = new Core.PropertyReference(request.PropertyReference);
                var p  = Core.Property.CreateWithDescription(pr, request.PropertyDescription);

                this.context.Properties.Add(p);
                return(await context.SaveChangesAsync());
            }
 public async Task SaveEventAndCatalogContextChangesAsync(IntegrationEvent evt)
 {
     //Use of an EF Core resiliency strategy when using multiple DbContexts within an explicit BeginTransaction():
     //See: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency
     await ResilientTransaction.New(_propertyContext)
     .ExecuteAsync(async() => {
         // Achieving atomicity between original catalog database operation and the IntegrationEventLog thanks to a local transaction
         await _propertyContext.SaveChangesAsync();
         await _eventLogService.SaveEventAsync(evt, _propertyContext.Database.CurrentTransaction.GetDbTransaction());
     });
 }
Exemplo n.º 6
0
    public IActionResult Delete(int id)
    {
        var saleToDelete = db.Sales.Find(id);

        if (saleToDelete == null)
        {
            return(NotFound());
        }
        db.Sales.Remove(saleToDelete);
        db.SaveChangesAsync();
        return(NoContent());
    }
Exemplo n.º 7
0
        public async Task CreateRequestForCommandAsync <T>(Guid id)
        {
            var exists = await ExistAsync(id);

            var request = exists ?
                          throw new PropertyDomainException($"Request with {id} already exists") :
                                new ClientRequest()
                                {
                                    Id   = id,
                                    Name = typeof(T).Name,
                                    Time = DateTime.UtcNow
                                };

            _context.Add(request);

            await _context.SaveChangesAsync();
        }
        public async Task Add(Country item)
        {
            await _context.Country.AddAsync(item);

            await _context.SaveChangesAsync();
        }
        public async Task Add(LanguageModel item)
        {
            await _context.Languages.AddAsync(item);

            await _context.SaveChangesAsync();
        }
Exemplo n.º 10
0
        public async Task Add(CompanyModel item)
        {
            await _context.Company.AddAsync(item);

            await _context.SaveChangesAsync();
        }
Exemplo n.º 11
0
        public async Task Add(Area item)
        {
            await _context.Area.AddAsync(item);

            await _context.SaveChangesAsync();
        }
Exemplo n.º 12
0
        public async Task Add(PaymentGateway item)
        {
            await _context.PaymentGateway.AddAsync(item);

            await _context.SaveChangesAsync();
        }
Exemplo n.º 13
0
        public async Task Add(PlanTypeModel item)
        {
            await _context.PlanType.AddAsync(item);

            await _context.SaveChangesAsync();
        }
Exemplo n.º 14
0
        public async Task Add(SubscriptionPlanModel item)
        {
            await _context.SubscriptionPlans.AddAsync(item);

            await _context.SaveChangesAsync();
        }