public async Task CreateAsync(string name, string email, string imageURL, string speciality, string departmentName) { var department = await this.db.Departments .Where(d => d.Name == departmentName) .FirstOrDefaultAsync(); var doctor = new Doctor { Name = name, Email = email, ImageURL = imageURL, Speciality = speciality, Department = department }; db.Add(doctor); db.Departments .Where(d => d.Id == department.Id) .FirstOrDefault() .Doctors .Add(doctor); await db.SaveChangesAsync(); }
public async Task <bool> Delete(int id) { var disease = await db.Diseases .SingleOrDefaultAsync(m => m.Id == id); if (disease == null) { return(false); } this.db.Diseases.Remove(disease); await db.SaveChangesAsync(); return(true); }