public IActionResult Create([Bind("last_name,first_name,phone,email,preferred_name,address,city,state,country,dob,user_id,profile_type,education_level,status,marital_status")] mp_clinician mp_profile)
 {
     if (ModelState.IsValid)
     {
         _clinicianService.Add(mp_profile);
         return(RedirectToAction(nameof(Index)));
     }
     return(View(mp_profile));
 }
Exemplo n.º 2
0
        public void Update(mp_clinician profile)
        {
            var old = _context.mp_clinician.FirstOrDefault(e => e.id == profile.id);

            profile.created_at = old.created_at;

            _context.Entry(old).CurrentValues.SetValues(profile);
            _context.SaveChanges();
        }
Exemplo n.º 3
0
        public Guid Add(mp_clinician profile)
        {
            profile.id         = Guid.NewGuid();
            profile.created_at = DateTime.Now;
            _context.mp_clinician.Add(profile);
            _context.SaveChanges();

            return(profile.id);
        }
 public DoctorModel(mp_clinician clinician)
 {
     clinician ??= new mp_clinician();
     id       = clinician.id;
     fullName = string.Format("{0} {1}", clinician.first_name, clinician.last_name);
     title    = clinician.area_of_interest.HasValue ? Options.GetLookupName(clinician.area_of_interest.Value) : null;
     imageUrl = FileUtil.GetImageLocation(clinician.user_id);
     about    = clinician.about;
     address  = clinician.address;
 }
 public PersonModel(mp_clinician clinician)
 {
     id              = clinician.id;
     first_name      = clinician.first_name;
     last_name       = clinician.last_name;
     fullName        = string.Format("{0} {1}", clinician.first_name, clinician.last_name);
     preferred_name  = clinician.preferred_name;
     title           = Options.GetLookupName(clinician.area_of_interest.Value);
     imageUrl        = FileUtil.GetImageLocation(clinician.user_id);
     about           = clinician.about;
     role            = "clinician";
     email           = clinician.email;
     dob             = clinician.dob;
     address         = clinician.address;
     phone           = clinician.phone;
     country         = clinician.country;
     state           = clinician.state;
     city            = clinician.city;
     marital_status  = clinician.marital_status;
     education_level = clinician.education_level;
 }
        public async Task <IActionResult> Edit(Guid id, mp_clinician mp_profile)
        {
            if (id != mp_profile.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                var collection = Request.Form;
                try
                {
                    //add languages
                    if (!string.IsNullOrEmpty(collection["language_spoken"]))
                    {
                        var languages_spoken    = collection["language_spoken"].ToString().Split(',');
                        var applicant_languages = new List <mp_clinician_language>();
                        _languageService.DeleteClinicianLanguage(id);
                        foreach (var language in languages_spoken)
                        {
                            applicant_languages.Add(new mp_clinician_language {
                                clinician_id = id, language = Convert.ToInt32(language)
                            });
                        }
                        _languageService.AddClinicianLanguage(applicant_languages);
                    }

                    string rootDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).Replace("file:\\", "") + "\\Uploads\\";
                    if (!Directory.Exists(rootDir))
                    {
                        Directory.CreateDirectory(rootDir);
                    }
                    var doc_type = collection["doc_type"].ToString().Split(',');

                    var clinicianDocuments = _profileDocumentService.GetByClinician(id);
                    var profilePhoto       = collection.Files["profile_img"];
                    var resume             = collection.Files["resume"];
                    var certificate        = collection.Files["certificate"];
                    if (profilePhoto != null)
                    {
                        string uploadsFolder = Path.Combine("wwwroot", "images", "applicant");
                        string filePath      = Path.Combine(uploadsFolder, id + ".jpg");
                        using var fileStream = new FileStream(filePath, FileMode.Create);
                        await profilePhoto.CopyToAsync(fileStream);
                    }
                    if (resume != null)
                    {
                        //save the file
                        var path = rootDir + "/" + resume.FileName;
                        using (var stream = System.IO.File.Create(path))
                        {
                            await resume.CopyToAsync(stream);
                        }
                        var docType = Convert.ToInt32(collection["Resume_doc_type"]);

                        mp_clinician_document applicant_Documents = new mp_clinician_document
                        {
                            clinician_id  = id,
                            document_type = docType,
                            path          = path
                        };

                        var document = clinicianDocuments.FirstOrDefault(x => x.document_type == docType);
                        if (document != null)
                        {
                            _profileDocumentService.RemoveProfileDocument(document.id);
                        }
                        _profileDocumentService.Add(applicant_Documents);
                    }
                    if (certificate != null)
                    {
                        //save the file
                        var path = rootDir + "/" + certificate.FileName;
                        using (var stream = System.IO.File.Create(path))
                        {
                            await certificate.CopyToAsync(stream);
                        }
                        var docType = Convert.ToInt32(collection["Certificate_doc_type"]);
                        mp_clinician_document applicant_Documents = new mp_clinician_document
                        {
                            clinician_id  = id,
                            document_type = docType,
                            path          = path
                        };

                        var document = clinicianDocuments.FirstOrDefault(x => x.document_type == docType);
                        if (document != null)
                        {
                            _profileDocumentService.RemoveProfileDocument(document.id);
                        }
                        _profileDocumentService.Add(applicant_Documents);
                    }

                    //update the education information of the applicant

                    var name_of_school    = collection["name_of_school"].ToList();
                    var address_of_school = collection["address_of_school"].ToList();
                    var certifications    = collection["certification"].ToList();

                    var applicant_educations = new List <mp_clinician_education>();
                    _educationService.DeleteClinicianEducation(id);
                    for (var j = 0; j < name_of_school.Count(); j++)
                    {
                        applicant_educations.Add(new mp_clinician_education {
                            clinician_id = id, address = address_of_school[j], school = name_of_school[j], certification = certifications[j]
                        });
                    }

                    _educationService.AddClinicianEducation(applicant_educations);

                    var practice_hospital = collection["practice_hospital"].ToList();
                    var practice_city     = collection["practice_city"].ToList();
                    var practice_role     = collection["practice_role"].ToList();
                    var practice_duration = collection["practice_duration"].ToList();

                    var applicant_practices = new List <mp_clinician_practice>();
                    for (var j = 0; j < practice_hospital.Count(); j++)
                    {
                        if (!string.IsNullOrEmpty(practice_hospital[j]) && !string.IsNullOrEmpty(practice_city[j]) && !string.IsNullOrEmpty(practice_duration[j]) && !string.IsNullOrEmpty(practice_role[j]))
                        {
                            applicant_practices.Add(new mp_clinician_practice {
                                clinician_id = id, hospital = practice_hospital[j], city = practice_city[j], duration = practice_duration[j], role = practice_role[j]
                            });
                        }
                    }
                    _practiceService.DeleteClinicianPractice(id);
                    _practiceService.AddClinicianPractice(applicant_practices);

                    //add other activities

                    var activities = collection["activity_outstanding_work"].ToList();
                    var activity_outstanding_work = new List <mp_clinician_other_activities>();
                    _otherActivitiesService.DeleteClinicianActivities(id);
                    foreach (var activity in activities)
                    {
                        activity_outstanding_work.Add(new mp_clinician_other_activities {
                            clinician_id = id, activity = activity, activity_type = "activity_outstanding_work"
                        });
                    }
                    _otherActivitiesService.AddClinicianActivities(activity_outstanding_work);

                    activities = collection["activity_scholary"].ToList();
                    activity_outstanding_work = new List <mp_clinician_other_activities>();

                    foreach (var activity in activities)
                    {
                        activity_outstanding_work.Add(new mp_clinician_other_activities {
                            clinician_id = id, activity = activity, activity_type = "activity_scholary"
                        });
                    }
                    _otherActivitiesService.AddClinicianActivities(activity_outstanding_work);

                    activities = collection["activity_social"].ToList();
                    activity_outstanding_work = new List <mp_clinician_other_activities>();

                    foreach (var activity in activities)
                    {
                        activity_outstanding_work.Add(new mp_clinician_other_activities {
                            clinician_id = id, activity = activity, activity_type = "activity_social"
                        });
                    }
                    _otherActivitiesService.AddClinicianActivities(activity_outstanding_work);

                    _clinicianService.Update(mp_profile);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!_clinicianService.ProfileExists(mp_profile.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Edit)));
            }
            return(View(mp_profile));
        }