Пример #1
0
        public async Task <IHttpActionResult> Add(PayAddDto model)
        {
            bool result = await _payService.Add(model);

            if (!result)
            {
                return(BadRequest());
            }

            return(Ok());
        }
Пример #2
0
        public async Task <bool> Add(PayAddDto model)
        {
            try
            {
                Pay entity = new Pay
                {
                    Id       = Guid.NewGuid(),
                    PayType  = model.PayType,
                    Total    = model.Total,
                    CourseId = model.CourseId,
                    UserId   = model.UserId
                };

                _context.Pay.Add(entity);
                await _context.SaveChangesAsync();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }