Пример #1
0
 public AktuelDto UpdateAktuel(AktuelDto dto)
 {
     if (repository.Update(dto) != null)
     {
         return(dto);
     }
     return(null);
 }
Пример #2
0
 public AktuelDto AddAktuel(AktuelDto dto)
 {
     if (repository.Add(dto) != null)
     {
         return(dto);
     }
     return(null);
 }
Пример #3
0
        public IActionResult Post([FromBody] AktuelDto aktuel)
        {
            if (ModelState.IsValid && aktuelService.AddAktuel(aktuel) != null)
            {
                return(Ok(aktuel));
            }

            return(BadRequest());
        }
Пример #4
0
        public AktuelDto AddOrGetAktuel(AktuelDto dto)
        {
            var aktuel = repository.First(x => x.NewsId == dto.NewsId & x.CompanyId == dto.CompanyId);

            if (aktuel == null)
            {
                return(((dto = this.AddAktuel(dto)) != null) ? dto : null);
            }

            return(aktuel);
        }
Пример #5
0
        public IActionResult Put(int?id, [FromBody] AktuelDto aktuel)
        {
            if (!id.HasValue)
            {
                return(BadRequest());
            }

            var akt = aktuelService.GetAktuel(id.Value);

            if (akt == null)
            {
                return(NotFound());
            }
            aktuel.Id = akt.Id;
            if (ModelState.IsValid && aktuelService.UpdateAktuel(aktuel) != null)
            {
                return(Ok(aktuel));
            }

            return(BadRequest());
        }