public Task <bool> Handle(RegisterDoctorCommand request, CancellationToken cancellationToken) { if (!request.IsValid()) { NotifyValidationErrors(request); return(Task.FromResult(false)); } var doctor = new Doctor(Guid.NewGuid(), request.Name, request.Email, request.Role, request.Reservations); if (_doctorRepository.GetByEmail(doctor.Email) != null) { _mediator.RaiseEvent(new DomainNotification(request.MessageType, "E-mail is already registered.")); return(Task.FromResult(false)); } _doctorRepository.Add(doctor); if (Commit()) { _mediator.RaiseEvent(new DoctorRegisteredEvent(doctor.Id, doctor.Name, doctor.Email, doctor.Reservations)); } return(Task.FromResult(true)); }
public async Task <IActionResult> Register(RegisterViewModel model, string returnUrl = null) { ViewData["ReturnUrl"] = returnUrl; var clinics = new List <SelectListItem>(); clinics = _clinicRepository.GetAll() .Select(a => new SelectListItem { Text = a.Name, Value = a.Id.ToString() } ).ToList(); model.Clinics = clinics; if (ModelState.IsValid) { var clinic = _clinicRepository.Get(model.ClinicId); var user = new User { UserName = model.Email, Email = model.Email, EmailConfirmed = false, ClinicId = model.ClinicId, Clinic = clinic }; var errors = await _doctorRepository.Add(user, model.Password); if (errors == null) { _logger.LogInformation("Doctor added"); return(RedirectToLocal(returnUrl)); } else { AddErrors(errors); } } return(View(model)); }
public ActionResult Create([Bind(Include = "Id,Name,SpecializationId")] Doctor doctor) { if (ModelState.IsValid) { repo.Add(doctor); return(RedirectToAction("Index")); } return(View(doctor)); }
public Task Handle(RegisterNewDoctorCommand message, CancellationToken cancellationToken) { if (!message.IsValid()) { NotifyValidationErrors(message); return(Task.CompletedTask); } var doctor = new Doctor(message.DoctorId, message.CRM, message.Person); _doctorRepository.Add(doctor); if (Commit()) { Bus.RaiseEvent(new DoctorRegisteredEvent(message.DoctorId, message.CRM, message.Person)); } return(Task.CompletedTask); }
public ActionResult CreateDoctor(DoctorViewModel doctorViewModel) { if (ModelState.IsValid) { doctorRepository.Add(doctorViewModel.ToDomainModel()); return(RedirectToAction("Index")); } return(View(doctorViewModel)); }
public ActionResult Create(DoctorViewModel model) { try { _doctorRepository.Add(_mapper.Map <Doctor>(model)); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public async Task Adicionar(Doctor doctor) { if (!ExecutarValidacao(new DoctorValidation(), doctor)) { return; } if (await _doctorRepository.CrmExists(doctor)) { Notificar("This document has been already registered in our system!"); return; } await _doctorRepository.Add(doctor); }
public void Create(DoctorViewModel dto) { try { var doctor = _doctorRepository.Add(dto.ToMEDoctor()); UpdateDoctorIntoSpecialist(doctor.MEDoctorID, dto.MESpecialistIds.Select(x => int.Parse(x)).ToArray()); _unitOfWork.Commit(); } catch (Exception ex) { _logService.Create(ex); throw ex; } }
public async Task <ActionResult> Create(Doctor doctor) { if (ModelState.IsValid) { string UrlImage = ""; var files = HttpContext.Request.Form.Files; foreach (var Image in files) { if (Image != null && Image.Length > 0) { var file = Image; var uploads = Path.Combine(appEnvironment.WebRootPath, "images"); if (file.Length > 0) { var fileName = Guid.NewGuid().ToString().Replace("-", "") + Path.GetExtension(file.FileName); //var fileName = Guid.NewGuid().ToString().Replace("-", "") + file.FileName; using (var fileStream = new FileStream(Path.Combine(uploads, fileName), FileMode.Create)) { await file.CopyToAsync(fileStream); UrlImage = fileName; } } } } var data = new Doctor() { Name = doctor.Name, Address = doctor.Address, Email = doctor.Email, PhoneNo = doctor.PhoneNo, JoiningDate = doctor.JoiningDate, Age = doctor.Age, UrlImage = UrlImage, }; db.Add(data); return(RedirectToAction(nameof(Index))); } return(RedirectToAction("Index")); }
public async Task <IActionResult> Add(AddEditViewModel model) { var allClinics = _clinicRepository.GetAll() .Select(a => new SelectListItem { Text = a.Name, Value = a.Id.ToString() } ).ToList(); try { if (ModelState.IsValid) { var user = new Models.User { UserName = model.Email, Email = model.Email, EmailConfirmed = model.EmailConfirmed, ClinicId = model.ClinicId, }; var errors = await _doctorRepository.Add(user, model.Password); if (errors == null) { _logger.LogInformation("Doctor added"); return(RedirectToAction(nameof(List))); } else { AddErrors(errors); } } return(View(new AddEditViewModel { Clinics = allClinics })); } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); return(View(new AddEditViewModel { Clinics = allClinics })); } }
public void Add(Doctor doctor) { _doctorRepository.Add(doctor); }
public bool AddDoctor(DoctorDto doctor) { var entity = mapper.Map(doctor); return(doctorRepository.Add(entity)); }
public RedirectToActionResult Create(Doctor doctor) { Doctor newDoctor = _doctorRepository.Add(doctor); return(RedirectToAction("Details", new { id = newDoctor.DoctorId })); }
public async Task <DoctorDto> Post(DoctorDto doctorDto) { return(_mapper.ToDto(await _doctorRepository.Add(_mapper.FromDto(doctorDto)))); }
public void Post([FromBody] Doctor doctor) { _doctorRepository.Add(doctor); }
public async Task <ActionResult <Doctors> > PostDoctor(DoctorDTO doctorDTO) { var doctor = _doctorRepository.Add(doctorDTO); return(CreatedAtAction(nameof(GetDoctor), new { id = doctor.ID }, doctor)); }
public bool Add(DoctorView model) { return(_doctor.Add(model)); }
public void AddDoctor(Doctor doctor) { Doctor dr = doctor; doctorRepository.Add(dr); }