Пример #1
0
        public async Task <IActionResult> GetById([FromBody] SearchViewModel model)
        {
            try
            {
                var authUser = await _authUserService.FindByIdAsync(model.Id);

                return(Ok(authUser));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Пример #2
0
        public async Task <ActionResult> UpdateStatus([FromBody] SearchViewModel model)
        {
            try
            {
                var authUser = await _authUserService.FindByIdAsync(model.AuthUserId);

                var billDetails = _billDetailService.FindToEntity(x => x.AuthUserId == authUser.Id && x.IsActivated == false);
                if (billDetails == null)
                {
                    return(BadRequest("Model is not exists"));
                }
                BillViewModel bill = new BillViewModel();
                bill.Id         = new Guid();
                bill.Status     = "Chờ Duyệt";
                bill.AuthUserId = authUser.Id;
                bill.Total      = model.Total;
                bill.Created    = DateTime.Now;
                //addpromotion
                await _billService.CreateAsync(bill);

                var bill_Db = _billService.FindToEntity(x => x.AuthUserId == authUser.Id).OrderBy(a => a.Created).ToList().Last();
                foreach (var item in billDetails)
                {
                    item.IsActivated = true;
                    item.BillId      = bill_Db.Id;
                    await _billDetailService.UpdateAsync(item);
                }
                return(Ok());
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }