public async Task<IActionResult> UpdateAsync(string nameIndustry, IndustryMeta industrymeta)
 {
     var code = await _industryService.UpdateAsync(nameIndustry, industrymeta);
     return Ok(code);
 }
        public async Task <ActionResultReponese <string> > UpdateAsync(string nameIndustry, IndustryMeta industryMeta)
        {
            var isnameIndustry = await _iindustryRepository.checkexitNameIndustry(nameIndustry);

            if (!isnameIndustry)
            {
                return(new ActionResultReponese <string>(-31, "NameIndustry khong ton tai", "Industry"));
            }

            var getInfoIndustry = await _iindustryRepository.GetInfoAsync(nameIndustry);

            var isDepartmenrt = await _iDepartmentRepository.CheckExitsByIdDepartment(industryMeta.IdDepartment);

            if (!isDepartmenrt)
            {
                return(new ActionResultReponese <string>(-31, "idDepartment khong ton tai", "Department"));
            }

            var _industryUpdate = new Industry
            {
                IdIndustry   = getInfoIndustry.IdIndustry?.Trim(),
                NameIndustry = industryMeta.NameIndustry?.Trim(),
                Address      = industryMeta.Address?.Trim(),
                Details      = industryMeta.Details?.Trim(),
                Email        = industryMeta.Email?.Trim(),
                IdDepartment = industryMeta.IdDepartment?.Trim(),
                PhoneNumber  = industryMeta.PhoneNumber?.Trim(),
                LastUpdate   = DateTime.Now,
                CreateDate   = getInfoIndustry.CreateDate,
                Deletetime   = null,
                IsActive     = true,
                IsDelete     = false,
            };
            var Result = await _iindustryRepository.UpdateAsync(_industryUpdate);

            if (Result >= 0)
            {
                return(new ActionResultReponese <string>(Result, "Update Nganh thanh cong", "Industry"));
            }
            return(new ActionResultReponese <string>(Result, "Update Nganh that bai", "Industry"));
        }
 public async Task<IActionResult> InsertAsync(string idDepartment,IndustryMeta industrymeta)
 {
     var code= await _industryService.InsertAsync(idDepartment, industrymeta);
     return Ok(code);
 }
        public async Task <ActionResultReponese <string> > InsertAsync(string idDepartment, IndustryMeta industryMeta)
        {
            var isdepartment = await _iDepartmentRepository.CheckExitsByIdDepartment(idDepartment);

            if (!isdepartment)
            {
                return(new ActionResultReponese <string>(-21, "IdDepartment khong ton tai", "Department"));
            }

            var isnameIndustry = await _iindustryRepository.checkexitNameIndustry(industryMeta.NameIndustry);

            if (isnameIndustry)
            {
                return(new ActionResultReponese <string>(-31, "NameIndustry da ton tai", "Industry"));
            }

            var _industry = new Industry
            {
                IdIndustry   = Guid.NewGuid().ToString(),
                NameIndustry = industryMeta.NameIndustry?.Trim(),
                IdDepartment = idDepartment?.Trim(),
                Address      = industryMeta.Address?.Trim(),
                Email        = industryMeta.Email?.Trim(),
                PhoneNumber  = industryMeta.PhoneNumber?.Trim(),
                Details      = industryMeta.Details?.Trim(),
                CreateDate   = DateTime.Now,
                Deletetime   = null,
                LastUpdate   = null,
                IsActive     = true,
                IsDelete     = false,
            };
            var code = await _iindustryRepository.InsertAsync(_industry);

            if (code >= 0)
            {
                return(new ActionResultReponese <string>(code, "Insert thanh cong", "Industry"));
            }
            return(new ActionResultReponese <string>(code, "Insert that bai", "Industry"));
        }