public ActionResult AddVolunteerDoctor(SignUpViewModel signUpViewModel) { try { var user = new User(); var volunteerDoctor = new VolunteerDoctor(); var signuphelper = new SignUpHelper(); user = signuphelper.GetUserobj(signUpViewModel); var result = _userService.Save(user); var userid = _userService.GetLastId(signUpViewModel.Email); signUpViewModel.UserId = userid.Data; volunteerDoctor = signuphelper.GetVolunteerDoctorobj(signUpViewModel); var result2 = _volunteerDoctorService.Save(volunteerDoctor); if (result.HasError) { ViewBag.Message = result.Message; return(Content(result.Message)); } if (result2.HasError) { ViewBag.Message = result2.Message; return(Content(result2.Message)); } return(RedirectToAction("GetAllVolunteerDoctor")); } catch (Exception e) { return(Content(e.Message)); } }
public Result <VolunteerDoctor> Save(VolunteerDoctor Entity) { var result = new Result <VolunteerDoctor>(); try { var objtosave = _context.VolunteerDoctors.FirstOrDefault(u => u.DoctorId == Entity.DoctorId); if (objtosave == null) { objtosave = new VolunteerDoctor(); _context.VolunteerDoctors.Add(Entity); } else { objtosave = new VolunteerDoctor(); objtosave = Entity; } if (!IsValid(objtosave, result)) { return(result); } _context.SaveChanges(); } catch (Exception e) { result.HasError = true; result.Message = e.Message; } return(result); }
public bool IsValid(VolunteerDoctor obj, Result <VolunteerDoctor> result) { if (!ValidationHelper.IsStringValid((obj.DoctorId.ToString()))) { result.HasError = true; result.Message = "Invalid VolunteerDoctorId"; return(false); } return(true); }
public VolunteerDoctor GetUpdatedVolunteerDoctorObj(SignUpViewModel signUp, VolunteerDoctor volunteerDoctor) { if (signUp.HospitalName != null) { volunteerDoctor.HospitalName = signUp.HospitalName; } if (signUp.SpecialDomain != null) { volunteerDoctor.SpecialDomain = signUp.SpecialDomain; } return(volunteerDoctor); }
public SignUpViewModel SignUpViewModel(VolunteerDoctor voldoc, User user) { var signUp = new SignUpViewModel(); signUp.UserId = user.UserId; signUp.Name = user.Name; signUp.Email = user.Email; signUp.Address = user.Address; signUp.Password = user.Password; signUp.Phone = user.Phone; signUp.DOB = user.DOB; signUp.SpecialDomain = voldoc.SpecialDomain; return(signUp); }
public VolunteerDoctor GetVolunteerDoctorobj(SignUpViewModel signUp) { VolunteerDoctor volunteerDoctor = new VolunteerDoctor { UserId = signUp.UserId, HospitalName = signUp.HospitalName, SpecialDomain = signUp.SpecialDomain }; if (signUp.HospitalName == null) { volunteerDoctor.HospitalName = "Not Mention Yet"; } return(volunteerDoctor); }
public ActionResult WorkShopDetails(int id) { try { var result = _workshopService.GetById(id); ListViewModel list = new ListViewModel(); list.WorkShop = result.Data; var result2 = _volunteerService.GetAll(); var volunteer = result2.Data.ToList(); var result3 = _volunteerDoctorService.GetAll(); var doctor = result3.Data.ToList(); var assign = _assignworkShopService.GetAllByWorkShopId(id); foreach (var p in assign.Data) { var obj = _userService.GetById(p.UserId); if (obj.Data.UserType.Equals("Volunteer")) { Volunteer vol = _volunteerService.GetById(obj.Data.UserId).Data; volunteer.Remove(vol); } else if (obj.Data.UserType.Equals("Doctor")) { VolunteerDoctor vol = _volunteerDoctorService.GetById(obj.Data.UserId).Data; doctor.Remove(vol); } } foreach (var p in doctor) { var doc = _volunteerDoctorService.GetVolunteerDoctorById(p.DoctorId).Data; var user = _userService.GetById(doc.UserId).Data; UserDoctorViewModel uv = new UserDoctorViewModel(); uv.UserId = user.UserId; uv.Email = user.Email; uv.Name = user.Name; uv.Phone = user.Phone; uv.SpecialDomain = doc.SpecialDomain; uv.CurrentLocation = doc.CurrentLocation; list.UserDoctorViewModel.Add(uv); } foreach (var p in volunteer) { var vol = _volunteerService.GetVolunteerById(p.VolunteerId).Data; var user = _userService.GetById(vol.UserId).Data; UserVolunteerViewModel uv = new UserVolunteerViewModel(); uv.UserId = user.UserId; uv.Email = user.Email; uv.Name = user.Name; uv.Phone = user.Phone; uv.JobDetails = vol.JobDetails; uv.CurrentLocation = vol.CurrentLocation; list.UserVolunteerViewModels.Add(uv); } if (result.HasError) { ViewBag.Message = result.Message; return(Content(result.Message)); } if (result2.HasError) { ViewBag.Message = result2.Message; return(Content(result2.Message)); } if (result3.HasError) { ViewBag.Message = result3.Message; return(Content(result3.Message)); } return(View(list)); } catch (Exception e) { return(Content(e.Message)); } }