Esempio n. 1
0
        public async Task <IActionResult> PutAppleAppRequestModel(long id, AppleAppRequestModel appleAppRequestModel)
        {
            if (id != appleAppRequestModel.Id)
            {
                return(BadRequest());
            }

            this.context.Entry(appleAppRequestModel).State = EntityState.Modified;

            try
            {
                await this.context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AppleAppRequestModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <ActionResult <AppleAppRequestModel> > GetAppleAppRequestModel(int id, string referenceId = null)
        {
            AppleAppRequestModel appleAppRequestModel = null;

            //var appleAppRequestModel = await this.context.AppleAppRequests.FindAsync(id);
            //this.context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
            if (referenceId != null)
            {
                appleAppRequestModel = await this.context.AppleAppRequests.AsNoTracking().Include(request => request.RequestedApplications).Include(request => request.RequestedDevices).FirstOrDefaultAsync(request => request.ReferenceId == referenceId && request.IsActive == true);
            }
            else
            {
                appleAppRequestModel = await this.context.AppleAppRequests.AsNoTracking().Include(request => request.RequestedApplications).Include(request => request.RequestedDevices).FirstOrDefaultAsync(request => request.Id == id && request.IsActive == true);
            }

            if (appleAppRequestModel == null)
            {
                return(NotFound());
            }

            //await this.context.Entry(appleAppRequestModel).Collection(request => request.RequestedDevices).EntityEntry.Collection(request => request.RequestedApplications).LoadAsync();
            //await this.context.Entry(appleAppRequestModel).Collection(request => request.RequestedDevices).LoadAsync();
            return(appleAppRequestModel);
        }