Пример #1
0
        public async Task <IActionResult> Post([FromBody] Parceria.Models.Parceria payload)
        {
            var result = await _parceriaService.InsertParceria(payload);

            if (result)
            {
                return(Ok());
            }

            return(StatusCode(500));
        }
Пример #2
0
        public async Task <IActionResult> Put(int codigo, [FromBody] Parceria.Models.Parceria payload)
        {
            payload.Codigo = codigo;
            var result = await _parceriaService.UpdateParceria(payload);

            if (result)
            {
                return(Ok());
            }

            return(StatusCode(500));
        }
Пример #3
0
        public async Task <IActionResult> Edit([FromForm] Parceria.Models.Parceria parceria)
        {
            try
            {
                var result = await _apiCaller.Put <Parceria.Models.Parceria>(parceria,
                                                                             _config.GetConnectionString("API"), $"/Parceria/{parceria.Codigo}");

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Пример #4
0
        public async Task <IActionResult> Create([FromForm] Parceria.Models.Parceria parceria)
        {
            try
            {
                await _apiCaller.Post <Parceria.Models.Parceria>(parceria,
                                                                 _config.GetConnectionString("API"), "/Parceria");

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }