Esempio n. 1
0
        public IActionResult Delete(int id)
        {
            if (id <= 0)
            {
                return(NotFound(id));
            }

            try
            {
                var idSkill = _skillService.GetById(id);

                if (idSkill == null)
                {
                    return(NotFound("Id not found !"));
                }
                else
                {
                    var data = _skillService.DeleteSkill(id);

                    return(Ok("Success Delete Data : " + id));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> DeleteSkill(int id)
        {
            ServiceResponse <List <GetSkillDto> > response = await _skillService.DeleteSkill(id);

            if (!response.Success)
            {
                return(NotFound(response));
            }
            return(Ok(response));
        }
        public IActionResult Delete(string SkillId)
        {
            var result = service.DeleteSkill(SkillId);

            return(Ok(new SuccessResponse <string>
            {
                Code = 200,
                Data = result
            }));
        }
Esempio n. 4
0
        public async Task <IActionResult> DeleteSkill(int id)
        {
            var app = await _skillService.DeleteSkill(id);

            if (app.AppResult.Result == false)
            {
                return(BadRequest(app.AppResult));
            }
            return(Ok(app.AppResult));
        }
Esempio n. 5
0
 public IActionResult DeleteSkill(int id)
 {
     try
     {
         _skillService.DeleteSkill(id);
         return(Ok(new { message = "Success Delete" }));
     }
     catch (System.Exception exp)
     {
         _logger.LogError(exp.Message);
         return(BadRequest(new { message = "Fail to delete skill" }));
     }
 }
Esempio n. 6
0
        public async Task BusinessTestFor_DeleteSkill_Possitive()
        {
            try
            {
                var result = await _skillService.DeleteSkill(_skill.SkillName);

                if (result == 1)
                {
                    testResult = "BusinessTestFor_DeleteSkill_Possitive=" + "True";
                    fileUtility.WriteTestCaseResuItInText(testResult);
                    // Write test case result in xml file
                    if (config["env"] == "development")
                    {
                        cases newcase = new cases
                        {
                            TestCaseType   = "Business",
                            Name           = "BusinessTestFor_DeleteSkill_Possitive",
                            expectedOutput = "True",
                            weight         = 5,
                            mandatory      = "True",
                            desc           = "na"
                        };
                        await fileUtility.WriteTestCaseResuItInXML(newcase);
                    }
                }
                else
                {
                    Assert.Equal(1, result);
                }
            }
            catch (Exception exception)
            {
                var res = exception.Message;
                testResult = "BusinessTestFor_DeleteSkill_Possitive=" + "False";
                fileUtility.WriteTestCaseResuItInText(testResult);
                // Write test case result in xml file
                if (config["env"] == "development")
                {
                    cases newcase = new cases
                    {
                        TestCaseType   = "Business",
                        Name           = "BusinessTestFor_DeleteSkill_Possitive",
                        expectedOutput = "False",
                        weight         = 5,
                        mandatory      = "False",
                        desc           = "na"
                    };
                    await fileUtility.WriteTestCaseResuItInXML(newcase);
                }
            }
        }
Esempio n. 7
0
        public async Task <ActionResult <int> > DestroySkill(String SkillName)
        {
            try
            {
                //Business logic to call skill servic method which returns 1 on successfull deletion of skill
                var result = await _skillService.DeleteSkill(SkillName);

                return(result);
            }
            catch (Exception exception)
            {
                return(BadRequest(exception.ToString()));
            }
        }
Esempio n. 8
0
        public ActionResult RemoveSkillPost(string id)
        {
            {
                var isDeleted = _skillService.DeleteSkill(User.Identity.GetUserId(), id);
                if (isDeleted)
                {
                    return(Json(new { success = true }));
                }
            }
            var skill = GetSkill(User.Identity.GetUserId(), id);

            ModelState.AddModelError(string.Empty, "The item cannot be removed");
            return(PartialView("_RemoveSkill", skill));
        }
Esempio n. 9
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            TempData["SkillInoperativeMsg"] = "";
            try
            {
                await _skillService.DeleteSkill(id);

                await _skillRepository.DeleteSkill(id);

                await _skillRepository.Save();
            }
            catch (BrokenCircuitException)
            {
                HandleBrokenCircuit();
            }

            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 10
0
        public async Task <AppResult> ImportFile(FileUpload file, int?id)
        {
            AppResult appResult = new AppResult();
            var       fileName  = file.files.FileName;

            if (!ImportFileHandling.HasFileExtension(Path.GetExtension(fileName)))
            {
                appResult.Result  = false;
                appResult.Message = "CV Import Failed, Invalid file format!";
                return(appResult);
            }
            var list = await ImportFileHandling.GetInformationCV(file.files);

            if (list.Count > 0)
            {
                var resultCheckFile = ImportFileHandling.CheckFile(list);
                if (resultCheckFile.Result)
                {
                    int idPerson = 0;
                    List <SkillRequestModel> listSkill = new List <SkillRequestModel>();
                    List <int> listIdWorkHistory       = new List <int>();
                    List <SaveWorkHistoryResource> saveWorkHistoryResources = new List <SaveWorkHistoryResource>();
                    List <int> listIdEducation = new List <int>();
                    List <SaveEducationResource> saveEducationResources = new List <SaveEducationResource>();
                    List <int> listIdCertificate = new List <int>();
                    List <SaveCertificateResource> saveCertificateResources = new List <SaveCertificateResource>();
                    List <int>           listIdSkill        = new List <int>();
                    List <SkillResource> skillRequestModels = new List <SkillResource>();
                    List <int>           listIdProject      = new List <int>();
                    List <Project>       listProject        = new List <Project>();
                    try
                    {
                        using (TransactionScope txScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
                        {
                            Person person = ImportFileHandling.GetPerson(list);
                            Image  image  = await ImportFileHandling.GetImageCV(file.files);

                            if (id == null)
                            {
                                var resultPerson = await _personService.InsertPersonToImportFile(person, image);

                                appResult = resultPerson.AppResult;
                                idPerson  = resultPerson.PersonInfo.Id;
                            }
                            else
                            {
                                idPerson = (int)id;
                                if (idPerson > 0)
                                {
                                    var tempPerson = await _personService.GetPersonById(idPerson);

                                    var modelPerson = (Person)tempPerson;
                                    if (modelPerson != null)
                                    {
                                        person.Id = (int)id;
                                        var resultPerson = await _personService.UpdatePersonToImportFile(person, image);

                                        appResult = resultPerson.AppResult;
                                        if (appResult.Result)
                                        {
                                            var listWorkHistoryResourceByPersonId = await _workHistoryService.GetWorkHistoryByPersonId(idPerson);

                                            saveWorkHistoryResources = listWorkHistoryResourceByPersonId.ToList();
                                            if (saveWorkHistoryResources != null)
                                            {
                                                foreach (var item in saveWorkHistoryResources)
                                                {
                                                    listIdWorkHistory.Add(item.Id);
                                                }
                                                if (listIdWorkHistory != null)
                                                {
                                                    foreach (var item in listIdWorkHistory)
                                                    {
                                                        await _workHistoryService.DeleteWorkHistory(item);
                                                    }
                                                }
                                            }
                                            var listEducationByPersonId = await _educationService.GetEducationByPersonId(idPerson);

                                            saveEducationResources = listEducationByPersonId.ToList();
                                            if (saveEducationResources != null)
                                            {
                                                foreach (var item in saveEducationResources)
                                                {
                                                    listIdEducation.Add(item.Id);
                                                }
                                                if (listIdEducation != null)
                                                {
                                                    foreach (var item in listIdEducation)
                                                    {
                                                        await _educationService.DeleteEducation(item);
                                                    }
                                                }
                                            }
                                            var listCertificateByPersonId = await _certificateService.GetCertificateByPersonId(idPerson);

                                            saveCertificateResources = listCertificateByPersonId.ToList();
                                            if (saveCertificateResources != null)
                                            {
                                                foreach (var item in saveCertificateResources)
                                                {
                                                    listIdCertificate.Add(item.Id);
                                                }
                                                if (listIdCertificate != null)
                                                {
                                                    foreach (var item in listIdCertificate)
                                                    {
                                                        await _certificateService.DeleteCertificate(item);
                                                    }
                                                }
                                            }
                                            var listSkillByPeronId = await _skillService.GetSkillByPerson(idPerson);

                                            skillRequestModels = listSkillByPeronId.ToList();
                                            if (skillRequestModels != null)
                                            {
                                                foreach (var item in skillRequestModels)
                                                {
                                                    listIdSkill.Add(item.PersonCategoryId);
                                                }
                                                if (listIdSkill != null)
                                                {
                                                    foreach (var item in listIdSkill)
                                                    {
                                                        await _skillService.DeleteSkill(item);
                                                    }
                                                }
                                            }
                                            var listProjectByPersonId = await _projectService.GetProjectByPersonId(idPerson);

                                            listProject = listProjectByPersonId.ToList();
                                            if (listProject != null)
                                            {
                                                foreach (var item in listProject)
                                                {
                                                    listIdProject.Add(item.Id);
                                                }
                                                if (listIdProject != null)
                                                {
                                                    foreach (var item in listIdProject)
                                                    {
                                                        await _projectService.DeleteProject(item);
                                                    }
                                                }
                                            }
                                        }
                                        idPerson = resultPerson.PersonInfo.Id;
                                    }
                                    else
                                    {
                                        appResult.Result  = false;
                                        appResult.Message = "CV Import Failed, CV not exist";
                                        return(appResult);
                                    }
                                }
                            }
                            if (idPerson > 0)
                            {
                                List <CreateWorkHistoryResource> workHistoryResources = ImportFileHandling.GetListWorkHistory(list, idPerson);
                                if (workHistoryResources != null)
                                {
                                    foreach (var item in workHistoryResources)
                                    {
                                        if (item != null)
                                        {
                                            await _workHistoryService.CreateWorkHistory(item);
                                        }
                                    }
                                }
                                List <CreateEducationResource> createEducationResources = ImportFileHandling.GetListEducation(list, idPerson);
                                if (createEducationResources != null)
                                {
                                    foreach (var item in createEducationResources)
                                    {
                                        if (item != null)
                                        {
                                            await _educationService.CreateEducation(item);
                                        }
                                    }
                                }
                                List <CreateCertificateResource> createCertificateResources = ImportFileHandling.GetListCertifiate(list, idPerson);
                                if (createCertificateResources != null)
                                {
                                    foreach (var item in createCertificateResources)
                                    {
                                        if (item != null)
                                        {
                                            await _certificateService.CreateCertificate(item);
                                        }
                                    }
                                }
                                List <Category> categories = ImportFileHandling.GetListCategory(list);
                                List <int>      Category   = new List <int>();
                                if (categories != null)
                                {
                                    listSkill = new List <SkillRequestModel>();
                                    foreach (var groupItem in categories)
                                    {
                                        var resultCategory = await _categoryService.InsertCategory(groupItem);

                                        int idCategory = resultCategory.Category.Id;
                                        Category.Add(idCategory);
                                        List <int> listTechnology = new List <int>();
                                        foreach (var item in groupItem.Technologies)
                                        {
                                            item.CategoryId = idCategory;
                                            var resultTechnology = await _technologyService.InsertTechnology(item);

                                            int idTechnology = resultTechnology.Technology.Id;
                                            listTechnology.Add(idTechnology);
                                        }
                                        SkillRequestModel skill = new SkillRequestModel
                                        {
                                            PersonId     = idPerson,
                                            CategoryId   = idCategory,
                                            TechnologyId = listTechnology
                                        };
                                        listSkill.Add(skill);
                                    }
                                    if (listSkill.Count > 0)
                                    {
                                        foreach (var item in listSkill)
                                        {
                                            await _skillService.InserSkill(item);
                                        }
                                    }
                                }
                                List <Project> projects = ImportFileHandling.GetListProject(list, idPerson);
                                if (projects != null)
                                {
                                    foreach (var gorupItem in projects)
                                    {
                                        List <ProjectTechnology> projectTechnologies = new List <ProjectTechnology>();
                                        var resultProject = await _projectService.InsertProject(gorupItem);

                                        int idProject = resultProject.Project.Id;
                                        foreach (var item in gorupItem.Technologies)
                                        {
                                            ProjectTechnology projectTechnology = new ProjectTechnology
                                            {
                                                ProjectId    = idProject,
                                                TechnologyId = await _technologyService.GetTechnologyByPersonAndNameAsync(idPerson, item.Name)
                                            };
                                            projectTechnologies.Add(projectTechnology);
                                        }
                                        await _projectTechnologyService.InsertListTechnologyAsync(projectTechnologies);
                                    }
                                }
                            }
                            txScope.Complete();
                        }
                    }
                    catch
                    {
                        appResult.Result  = false;
                        appResult.Message = "CV Import Failed, file is invalid!";
                    }
                }
                else
                {
                    appResult.Result  = false;
                    appResult.Message = resultCheckFile.Message;
                }
            }
            else
            {
                appResult.Result  = false;
                appResult.Message = "CV Import Failed, file is invalid!";
            }
            return(appResult);
        }
Esempio n. 11
0
        public async Task <IHttpActionResult> Delete(int id)
        {
            await Task.Run(() => _skillService.DeleteSkill(id));

            return(Ok());
        }