username@email.com
2024-09-25 9ff87793beacf5069c374b6e6274fa651179a7f3
cylsg/cylsg.Application/Users/UserAppService.cs
@@ -117,9 +117,10 @@
            var userWorkerRes = new BaseRepository<UserWorker>();
            bool res;
            if (userWorkerDto.Id > 0)
            var userWorker1 = await userWorkerRes.GetFirstAsync(x => x.UserId == userid && x.IsEn == true && x.IsDeleted == false);
            if (userWorker1!=null)
            {
                var userWorker1 = await userWorkerRes.GetByIdAsync(userWorkerDto.Id);
               //.GetByIdAsync(userWorkerDto.Id);
                userWorker1.IdCardBack = userWorkerDto.IdCardBack;
                userWorker1.IdCardFace = userWorkerDto.IdCardFace;
                userWorker1.name = userWorkerDto.name;
@@ -206,9 +207,21 @@
            var userCompanyRes = new BaseRepository<UserCompany>();
            bool res;
            if (userCompanyDto.Id > 0)
            var userCompany1 = await userCompanyRes.GetFirstAsync(x=>x.UserId == userid && x.IsEn == true && x.IsDeleted == false);
            if (userCompany1 != null)
            {
                var userCompany1 = await userCompanyRes.GetByIdAsync(userCompanyDto.Id);
                if(userCompany1.Suppliercode != userCompanyDto.Suppliercode)
                {
                    var count = await userCompanyRes.CountAsync(x => x.Suppliercode == userCompanyDto.Suppliercode && x.Id != userCompany1.Id && x.IsEn == true && x.IsDeleted == false);
                    if (count > 0)
                    {
                        userCompany1.IsAdmin = false;
                    }
                    else
                    {
                        userCompany1.IsAdmin = true;
                    }
                }
                userCompany1.BusinessLicense = userCompanyDto.BusinessLicense;
                userCompany1.Suppliername = userCompanyDto.Suppliername;
                userCompany1.Regtime = userCompanyDto.Regtime;
@@ -227,6 +240,16 @@
            }
            else
            {
                var count = await userCompanyRes.CountAsync(x => x.Suppliercode == userCompanyDto.Suppliercode && x.IsEn == true && x.IsDeleted == false);
                if (count > 0)
                {
                    userCompanyDto.IsAdmin = false;
                }
                else
                {
                    userCompanyDto.IsAdmin = true;
                }
                var userCompany = _mapper.Map<UserCompany>(userCompanyDto);
                userCompany.UpDataBy = NickName;
                userCompany.UpDataTime = DateTime.Now;