public async Task <IActionResult> PutLocationModel(int id, LocationModel locationModel) { if (id != locationModel.Id) { return(BadRequest()); } _context.Entry(locationModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LocationModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <UserModel> PutUserModel(int id, UserModel userModel) { if (id != userModel.Id) { } _context.Entry(userModel).State = EntityState.Modified; await _context.SaveChangesAsync(); return(userModel); }
public async Task <ActionResult <MedicalStateModel> > PostMedicalStateModel(MedicalStateModel medicalStateModel) { medicalStateModel.DiseaseModel = null; medicalStateModel.UserModel = null; if (!MedicalStateModelExists(medicalStateModel.UserModelId, medicalStateModel.DiseaseModelId)) { _context.MedicalStateModels.Add(medicalStateModel); } else { var medicalStateModeldelete = _context.MedicalStateModels.Where(c => c.UserModelId == medicalStateModel.UserModelId && c.DiseaseModelId == medicalStateModel.DiseaseModelId).FirstOrDefault(); _context.MedicalStateModels.Remove(medicalStateModeldelete); await _context.SaveChangesAsync(); } await _context.SaveChangesAsync(); return(CreatedAtAction("GetMedicalStateModel", new { id = medicalStateModel.Id }, medicalStateModel)); }
/// <summary> /// The FetchSaveInformationToDatabase. /// </summary> /// <returns>The <see cref="Task"/>.</returns> private async Task FetchSaveInformationToDatabase() { //_dbContext.Database.ExecuteSqlRaw("TRUNCATE TABLE Config.Country"); using CoronaDbContext dbcontext = CoronaDbContext.GetContext(); dbcontext.Database.ExecuteSqlRaw("TRUNCATE TABLE Config.GlobalInfo"); (AllResults all, List <CountryResult> countries) = await GetAllInfo().ConfigureAwait(false); var mappedCountries = countries.Select(c => _mapper.Map <Countries>(c)).ToList(); await dbcontext.CoronaInfos.AddAsync(new CoronaInfo { Countries = mappedCountries, UpdateDate = DateTimeOffset.UtcNow }); await dbcontext.All.AddAsync(_mapper.Map <GlobalInfo>(all)).ConfigureAwait(false); await dbcontext.SaveChangesAsync().ConfigureAwait(false); await SendToSignalRClient(); }