Example #1
0
 public ActionResult Create(NovelsForm novelsForm)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _novelsService.Add(new Novels()
             {
                 Title        = novelsForm.Title,
                 SerieId      = novelsForm.SerieId,
                 Authors      = novelsForm.Authors,
                 SerialNumber = novelsForm.SerialNumber,
                 Price        = novelsForm.Price,
                 Informations = novelsForm.Informations,
                 Langue       = novelsForm.Langue,
                 Dimension    = novelsForm.Dimension,
                 Published    = novelsForm.Published,
                 TypeId       = novelsForm.TypeId,
             });
             return(RedirectToAction(nameof(Index)));
         }
         catch (Exception ex)
         {
             return(View());
         }
     }
     return(BadRequest());
 }
Example #2
0
        public ActionResult Create()
        {
            NovelsForm novelform = new NovelsForm();

            novelform.SerieId = 0;
            novelform.Series  = GetSerie();
            novelform.TypeId  = 0;
            novelform.Types   = GetType();
            return(View(novelform));
        }
Example #3
0
 public IActionResult Add([FromBody] NovelsForm novels)
 {
     try
     {
         if (ModelState.IsValid)
         {
             _repository.Add(new Novels(novels.Id, novels.Title, novels.SerieId, novels.Serie, novels.Authors, novels.SerialNumber, novels.Price, novels.Informations, novels.Langue, novels.Dimension, novels.Published, novels.Type, novels.TypeId));;
             return(NoContent());
         }
         return(BadRequest());
     }
     catch (Exception ex)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError));
     }
 }