public async Task <IActionResult> Edit(Guid id, [Bind("Id,FirstMidName,LastName,ServiceId,Notes,Email,PhoneNumber,FacilityId")] MedicalProfessional medicalProfessional) { if (id != medicalProfessional.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(medicalProfessional); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MedicalProfessionalExists(medicalProfessional.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["FacilityId"] = new SelectList(_context.Facility, "Id", "FacilityName", medicalProfessional.FacilityId); ViewData["ServiceId"] = new SelectList(_context.Set <Service>(), "Id", "Id", medicalProfessional.ServiceId); return(View(medicalProfessional)); }
public void CreateMedicalProfessional(int userId) { using (var context = new HackathonEntities()) { var medicalProf = new MedicalProfessional() { UserId = userId }; context.MedicalProfessionals.Add(medicalProf); context.SaveChanges(); context.Dispose(); } }
public async Task <IActionResult> Create([Bind("Id,FirstMidName,LastName,ServiceId,Notes,Email,PhoneNumber,FacilityId")] MedicalProfessional medicalProfessional) { if (ModelState.IsValid) { medicalProfessional.Id = Guid.NewGuid(); _context.Add(medicalProfessional); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["FacilityId"] = new SelectList(_context.Facility, "Id", "FacilityName", medicalProfessional.FacilityId); ViewData["ServiceId"] = new SelectList(_context.Set <Service>(), "Id", "Category", medicalProfessional.ServiceId); return(View(medicalProfessional)); }
public void createNewMedicalProfessional(MedicalProfessionalRequest request, int userId) { using (var context = new HackathonEntities()) { var medicalProfessional = new MedicalProfessional() { UserId = userId, Address = request.Address, Email = request.email, Phone = request.Phone }; context.MedicalProfessionals.Add(medicalProfessional); context.SaveChanges(); context.Dispose(); } }
public async Task <IActionResult> PostMedicalProfessional([FromBody] MedicalProfessional medicalProfessional) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.MedicalProfessional.Add(medicalProfessional); //Task<Facility> Facility = _context.Facility.FirstOrDefaultAsync(f => f.Id == medicalProfessional.FacilityId); Facility facility = _context.Facility.Find(medicalProfessional.FacilityId); //facility.MedicalProfessionals.Add(medicalProfessional); await _context.SaveChangesAsync(); return(CreatedAtAction("GetMedicalProfessional", new { id = medicalProfessional.Id }, medicalProfessional)); } catch (DbUpdateException DBException) { return(BadRequest(DBException)); } }
public async Task <IActionResult> PutMedicalProfessional([FromRoute] Guid id, [FromBody] MedicalProfessional medicalProfessional) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != medicalProfessional.Id) { return(BadRequest()); } _context.Entry(medicalProfessional).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MedicalProfessionalExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public Frontdesk(MedicalProfessional user) { this.user = user; }