Ejemplo n.º 1
0
        public async Task <IActionResult> PutPayment(int id, PublicApi.v1.DTO.Payment payment)
        {
            if (id != payment.Id)
            {
                return(BadRequest());
            }

            _bll.Payments.Update(PublicApi.v1.Mappers.PaymentMapper.MapFromExternal(payment));
            await _bll.SaveChangesAsync();

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <PublicApi.v1.DTO.Payment> > PostPayment(PublicApi.v1.DTO.Payment payment)
        {
            _bll.Payments.Add(PublicApi.v1.Mappers.PaymentMapper.MapFromExternal(payment));
            await _bll.SaveChangesAsync();

            return(CreatedAtAction(
                       nameof(GetPayment),
                       new
            {
                version = HttpContext.GetRequestedApiVersion().ToString(),
                id = payment.Id
            }, payment));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult <PublicApi.v1.DTO.Payment> > PostPayment(PublicApi.v1.DTO.Payment payment)
        {
            if (!await _bll.Payments.BelongsToUserAsync(payment.Id, User.GetUserId()))
            {
                return(NotFound());
            }

            payment = PublicApi.v1.Mappers.PaymentMapper.MapFromInternal(
                _bll.Payments.Add(PublicApi.v1.Mappers.PaymentMapper.MapFromExternal(payment)));

            await _bll.SaveChangesAsync();

            payment = PublicApi.v1.Mappers.PaymentMapper.MapFromInternal(
                _bll.Payments.GetUpdatesAfterUOWSaveChanges(
                    PublicApi.v1.Mappers.PaymentMapper.MapFromExternal(payment)));


            return(CreatedAtAction("GetPayment", new
            {
                version = HttpContext.GetRequestedApiVersion().ToString(),
                id = payment.Id
            }, payment));
        }