public async Task <ServiceResult> Insert(RadnikUpsertDto radnikDto)
        {
            if (!await _dbContext.StacionarnaOdeljenja.AnyAsync(x => x.Id == radnikDto.StacionarnoOdeljenjeId))
            {
                return(ServiceResult.NotFound($"Stacionarno odeljenje sa ID-em {radnikDto.StacionarnoOdeljenjeId} nije pronadjeno"));
            }

            var licniPodaciResultTemp = await _licniPodaciService.Insert(radnikDto.LicniPodaci);

            if (!licniPodaciResultTemp.Succeeded)
            {
                return(ServiceResult.WithStatusCode(licniPodaciResultTemp.StatusCode, licniPodaciResultTemp.Message));
            }
            var licniPodaciResult = licniPodaciResultTemp.Data as LicniPodaciDto;

            var korisnickiNalogResultTemp = await _korisnikService.Insert(radnikDto.KorisnickiNalog);

            if (!korisnickiNalogResultTemp.Succeeded)
            {
                return(ServiceResult.WithStatusCode(korisnickiNalogResultTemp.StatusCode, korisnickiNalogResultTemp.Message));
            }
            var korisnickiNalogResult = korisnickiNalogResultTemp.Data as KorisnickiNalogDtoLL;

            var radnik = new Radnik
            {
                KorisnickiNalogId      = korisnickiNalogResult.Id,
                LicniPodaciId          = licniPodaciResult.Id,
                StacionarnoOdeljenjeId = radnikDto.StacionarnoOdeljenjeId
            };

            await _dbContext.AddAsync(radnik);

            await _dbContext.SaveChangesAsync();

            return(ServiceResult.OK(radnik));
        }
예제 #2
0
 public Korisnici Insert(KorisniciUpsertRequest request)
 {
     return(_service.Insert(request));
 }
 public Model.Korisnik Insert(KorisnikInsertRequest request)
 {
     return(_service.Insert(request));
 }
예제 #4
0
 public Model.Korisnik Insert([FromBody] Model.Requests.KorisnikInsertRequest request)
 {
     return(_service.Insert(request));
 }
예제 #5
0
 public KorisnikInsertRequest Insert(KorisnikInsertRequest Model)
 {
     return(_korisnikService.Insert(Model));
 }