public async Task <IActionResult> CreateDoctor(InputDoctorDTO doctor) { if (ModelState.IsValid) { await _doctorService.Add(doctor); } return(Ok($"Doutor {doctor.Name} cadastrado.")); }
public IActionResult Add(DoctorDto doctorDto) { if (_doctorService.Add(doctorDto) == null) { return(NotFound()); } return(Ok(doctorDto)); }
public IActionResult Add(Doctor doctor) { var result = _doctorService.Add(doctor); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public IActionResult SignUp(Doctor doctor) { if (ModelState.IsValid) { _doctorService.Add(doctor); HttpContext.Session.SetString("user", doctor.Login); _greeting.SetUser(doctor.Login); return(RedirectToAction("Index", "Home")); } return(View()); }
public IActionResult CreateDoctor(Doctor doctor) { if (ModelState.IsValid) { var newDoctor = new Doctor(); newDoctor.FirstName = doctor.FirstName; newDoctor.LastName = doctor.LastName; newDoctor = _doctorService.Add(newDoctor); return(RedirectToAction(nameof(ListDoctor))); } else { return(View()); } }
private async void SaveButton_Click(object sender, RoutedEventArgs e) { if (IsValidForm()) { doctor.Name = FirstNameBox.Text; doctor.LastName = LastNameBox.Text; doctor.IdLocalAccount = ((LocalAccountViewModel)AccountComboBox.SelectedItem).IdLocalAccount; doctor.WorkExperience = int.Parse(WorkExperienceBox.Text); DbStatus status = await doctorService.Add(Mapping.Mapper.Map <Doctor>(doctor)); OperationStatus = StatusHandler.Handle(OperationType.Create, status); Close(); } else { FieldValidation.WriteMessage(ErrorLabel, language.SelectValues); } }
public async Task <OkObjectResult> Post([FromBody] DoctorModel doctor) { var Doctor = new DoctorModel() { Name = doctor.Name, Surname = doctor.Surname, PhoneNumber = doctor.PhoneNumber, MedicalSpecialization = doctor.MedicalSpecialization }; try { var result = await _doctorService.Add(Doctor); return(Ok(result)); } catch (Exception ex) { throw ex; } }
private void AddDoctor() { Console.Clear(); Console.WriteLine("First Name:"); var firtsName = Console.ReadLine(); Console.WriteLine("Last Name:"); var lastName = Console.ReadLine(); Console.WriteLine("Qualification:"); var qualification = Console.ReadLine(); var id = doctors.GetMaxId() + 1; doctors.Add(new Doctor() { FirstName = firtsName, LastName = lastName, Id = id, Qualification = qualification }); }
private async void SaveButton_Click(object sender, RoutedEventArgs e) { doctor.Name = NameBox.Text; doctor.LastName = LastNameBox.Text; doctor.IdLocalAccount = ((LocalAccountViewModel)AccountComboBox.SelectedItem).IdLocalAccount; doctor.WorkExperience = int.Parse(WorkExperinceBox.Text); DbStatus status = await doctorService.Add(Mapping.Mapper.Map <Doctor>(doctor)); if (status == DbStatus.SUCCESS) { WindowHelper.WriteMessage(language.AddingSuccess, MessageLabel, true); } else if (status == DbStatus.EXISTS) { WindowHelper.WriteMessage(language.EntityExists, MessageLabel, false); } else if (status == DbStatus.DATABASE_ERROR) { WindowHelper.WriteMessage(language.DatabaseError, MessageLabel, false); } SaveButton.IsEnabled = false; }
public ActionResult CreateDoctor(DoctorViewModel vm) { using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork()) { var doctor = vm.ToEntity(); if (vm.Files != null) { var uploadFolderPath = HostingEnvironment.MapPath(string.Concat(SiteConstants.Instance.UploadFolderPath, "ImageDoctors")); if (!Directory.Exists(uploadFolderPath)) { Directory.CreateDirectory(uploadFolderPath); } foreach (var file in vm.Files) { if (file != null) { // If successful then upload the file var uploadResult = AppHelpers.UploadFile(file, uploadFolderPath, LocalizationService); if (!uploadResult.UploadSuccessful) { TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel { Message = uploadResult.ErrorMessage, MessageType = GenericMessages.danger }; unitOfWork.Rollback(); return(Json(new { Result = false, Message = "Vui lòng kiểm tra lại file thông tin", }, JsonRequestBehavior.AllowGet)); } doctor.Avatar = uploadResult.UploadedFileName; // Add the filename to the database //var uploadedFile = new UploadedFile //{ // Filename = uploadResult.UploadedFileName, // question.UrlFile = uploadResult.UploadedFileName; //}; //_uploadedFileService.Add(uploadedFile); } } } if (doctor.DepartmentId != null) { doctor.DepartmentManage = _doctorService.GetDepartmentById(doctor.DepartmentId); } _doctorService.Add(doctor); try { unitOfWork.Commit(); return(Json(new { Result = true, Message = "Thành công", }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { unitOfWork.Rollback(); LoggingService.Error(ex); return(Json(new { Result = false, Message = "Vui lòng kiểm tra lại thông tin", }, JsonRequestBehavior.AllowGet)); } } }
public ContentResult CreateDoctor(Doctor doctor) { doctorService.Add(doctor); doctorService.Save(); return(Content("<p>The doctor was created successfully!</p>")); }