Exemplo n.º 1
0
        public IActionResult Edit(int id, [Bind("id,document_type,profile_id,path")] mp_clinician_document mp_profile_document)
        {
            if (id != mp_profile_document.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _profileDocumentService.UpdateProfileDocument(mp_profile_document);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!_profileDocumentService.profileDocumentExists((int)mp_profile_document.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            //ViewData["profile_id"] = new SelectList(_context.mp_profile, "id", "first_name", mp_profile_document.profile_id);
            return(View(mp_profile_document));
        }
Exemplo n.º 2
0
 public IActionResult Create([Bind("document_type,profile_id,path")] mp_clinician_document mp_profile_document)
 {
     if (ModelState.IsValid)
     {
         _profileDocumentService.Add(mp_profile_document);
         return(RedirectToAction(nameof(Index)));
     }
     //ViewData["profile_id"] = new SelectList(_context.mp_profile, "id", "first_name", mp_profile_document.profile_id);
     return(View(mp_profile_document));
 }
Exemplo n.º 3
0
        public int UpdateProfileDocument(mp_clinician_document document)
        {
            var existing = _context.mp_clinician_document.FirstOrDefault(m => m.id == document.id);

            if (existing != null)
            {
                //do update
                document.created_at = existing.created_at;
                _context.Entry(existing).CurrentValues.SetValues(document);
                return(_context.SaveChanges());
            }
            return(0);
        }
        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));
        }
Exemplo n.º 5
0
 public void Add(mp_clinician_document applicant_doc)
 {
     _context.mp_clinician_document.Add(applicant_doc);
     _context.SaveChanges();
 }