/// <inheritdoc /> public async Task UpdatePlaceAsync(int id, Place place) { using (var context = new PhoneContextApi()) { context.Entry(place).State = EntityState.Modified; var placeInDb = await context.Places.FirstOrDefaultAsync(p => p.Id == id); await context.SaveChangesAsync(); } }
/// <inheritdoc /> public async Task DeletePhoneAsynk(int id) { using (var context = new PhoneContextApi()) { var phone = await context.Phones.FirstOrDefaultAsync(p => p.Id == id); phone.IsDeleted = 1; context.Entry(phone).State = EntityState.Modified; await context.SaveChangesAsync(); } }
/// <inheritdoc /> public async Task UpdatePhoneAsync(int id, PhoneItem phoneitem) { using (var context = new PhoneContextApi()) { var place = await context.Places.FirstOrDefaultAsync(p => p.Name == phoneitem.Place); var phone = new Phone() { Id = phoneitem.Id, Name = phoneitem.Name, Post = phoneitem.Post, Department = phoneitem.Department, Description = phoneitem.Description, Nomer = phoneitem.Nomer, PlaceId = place.Id }; context.Entry(phone).State = EntityState.Modified; var phoneInDb = await context.Phones.FirstOrDefaultAsync(p => p.Id == id); await context.SaveChangesAsync(); } }