示例#1
0
        public async Task <ActionResult <Response <DtoGamme> > > GetGammeById([FromRoute] int idGamme)
        {
            try
            {
                if (idGamme == 0)
                {
                    return(BadRequest(new Response <string>()
                    {
                        Error = "IdGamme can't be equal to 0", Succes = true
                    }));
                }
                var result = await BsGamme.GetById <DtoGamme>(idGamme);

                if (result == null)
                {
                    return(NotFound(new Response <string>()
                    {
                        Error = "The Gamme doesn't exist", Succes = true
                    }));
                }
                return(Ok(new Response <DtoGamme>()
                {
                    Error = "", Data = result, Succes = true
                }));
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, new Response <string[]>()
                {
                    Error = e.Message, Data = e.StackTrace.Split("\r\n"), Succes = false
                }));
            }
        }
示例#2
0
 public async Task <ActionResult <Response <IEnumerable <DtoGamme> > > > GetGammeByProducer([FromRoute] int idProducer)
 {
     try
     {
         if (idProducer == 0)
         {
             return(BadRequest(new Response <string>()
             {
                 Error = "IdProducer can't be equal to 0", Succes = true
             }));
         }
         if ((await BsProducer.GetById <DtoProducer>(idProducer)) == null)
         {
             return(NotFound(new Response <string>()
             {
                 Error = "The Producer doesn't exist", Succes = true
             }));
         }
         return(Ok(new Response <IEnumerable <DtoGamme> >()
         {
             Error = "", Data = await BsGamme.GetGammesByIdProducer(idProducer), Succes = true
         }));
     }
     catch (Exception e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, new Response <string[]>()
         {
             Error = e.Message, Data = e.StackTrace.Split("\r\n"), Succes = false
         }));
     }
 }
示例#3
0
 public async Task <ActionResult <Response <IEnumerable <DtoGamme> > > > GetAllGamme()
 {
     try
     {
         return(Ok(new Response <IEnumerable <DtoGamme> >()
         {
             Error = "", Data = await BsGamme.GetAll <DtoGamme>(), Succes = true
         }));
     }
     catch (Exception e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, new Response <string[]>()
         {
             Error = e.Message, Data = e.StackTrace.Split("\r\n"), Succes = false
         }));
     }
 }
示例#4
0
 public async Task <ActionResult <Response <DtoGamme> > > AddGamme([FromBody] DtoGammeAdd gamme)
 {
     try
     {
         if (gamme == null)
         {
             return(BadRequest(new Response <string>()
             {
                 Error = "The Gamme can't be null", Succes = true
             }));
         }
         return(Ok(new Response <DtoGamme>()
         {
             Error = "", Data = await BsGamme.Add <DtoGamme, DtoGammeAdd>(gamme), Succes = true
         }));
     }
     catch (Exception e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, new Response <string[]>()
         {
             Error = e.Message, Data = e.StackTrace.Split("\r\n"), Succes = false
         }));
     }
 }