// İlgili calisanin firmasini günceller. public async Task <ServiceResponse <CalisanGetirDto> > GuncelleFirma(CalisanGuncelleDto calisan) { ServiceResponse <CalisanGetirDto> response = new ServiceResponse <CalisanGetirDto>(); try{ Calisan guncelCalisan = await _context.Calisanlar.FirstOrDefaultAsync(c => c.Id == calisan.CalisanId); if (guncelCalisan != null) { guncelCalisan.FirmaId = calisan.YeniFirmaId; _context.Calisanlar.Update(guncelCalisan); await _context.SaveChangesAsync(); Calisan guncel = await _context.Calisanlar .Where(c => c.Id == guncelCalisan.Id) .Include(c => c.Firma) .Include(c => c.CalisanDepartmanlari).ThenInclude(cd => cd.Departman) .FirstOrDefaultAsync(); response.Basari = true; response.Mesaj = "Kayit Basariyla Guncellendi"; response.data = _mapper.Map <CalisanGetirDto>(guncel); } else { response.Mesaj = "Gecersiz Id : Calisan bulunamadı."; response.Basari = false; } } catch (Exception e) { response.Basari = false; response.Mesaj = e.Message; } return(response); }
public async Task <ActionResult <CalisanGetirDto> > CalisanFirmaGuncelle(CalisanGuncelleDto calisan) { return(Ok(await _calisanService.GuncelleFirma(calisan))); }