Пример #1
0
        public async Task <IActionResult> PutSystem([FromRoute] int id, [FromBody] guardian.service.Models.System system)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != system.Id)
            {
                return(BadRequest());
            }

            _context.Entry(system).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SystemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #2
0
        public async Task <IActionResult> PutModule([FromRoute] int id, [FromBody] Module @module)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != @module.Id)
            {
                return(BadRequest());
            }

            _context.Entry(@module).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ModuleExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #3
0
        public async Task <bool> AddBuddyAsync(Buddy buddy)
        {
            buddy.CreatedDate      = DateTime.UtcNow;
            buddy.LastModifiedDate = DateTime.UtcNow;
            _guardianContext.Buddies.Add(buddy);
            await _guardianContext.SaveChangesAsync();

            return(true);
        }
Пример #4
0
 public async Task CreateGroupMembership(GroupMembership gmem)
 {
     gmem.CreatedDate      = DateTime.UtcNow;
     gmem.LastModifiedDate = DateTime.UtcNow;
     _guardianContext.GroupMemberships.Add(gmem);
     await _guardianContext.SaveChangesAsync();
 }
Пример #5
0
        public async Task PurgeStaleSessionsAsync(List <LiveSession> locs)
        {
            foreach (var l in locs)
            {
                _guardianContext.Entry(l).State = EntityState.Deleted;
            }

            await _guardianContext.SaveChangesAsync();
        }
Пример #6
0
 public async Task <bool> AddBuddyAsync(Buddy buddy)
 {
     return(await _sqlAzureExecutionStrategy.ExecuteAsync <bool>(async() =>
     {
         _guardianContext.Buddies.Add(buddy);
         await _guardianContext.SaveChangesAsync();
         return true;
     }, CancellationToken.None));
 }
Пример #7
0
 public async Task PostMyLocation(LiveLocation loc)
 {
     _guardianContext.LiveLocations.Add(loc);
     await _guardianContext.SaveChangesAsync();
 }