public async Task <IHttpActionResult> Put(string id, NvKhuyenMaiTichDiemVm.Dto instance)
        {
            TransferObj <NvChuongTrinhKhuyenMai> result = new TransferObj <NvChuongTrinhKhuyenMai>();
            NvChuongTrinhKhuyenMai check = _service.FindById(instance.Id);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (check == null)
            {
                return(NotFound());
            }
            //if (id != instance.Id || check.TrangThai == (int)ApprovalState.IsComplete)
            //{
            //    return BadRequest();
            //}

            try
            {
                NvChuongTrinhKhuyenMai item = _service.UpdatePhieu(instance);
                _service.UnitOfWork.Save();
                result.Status = true;
                result.Data   = item;
                return(Ok(result));
            }
            catch (Exception e)
            {
                return(InternalServerError());
            }
        }
        public async Task <IHttpActionResult> Post(NvKhuyenMaiTichDiemVm.Dto instance)
        {
            TransferObj <NvChuongTrinhKhuyenMai> result = new TransferObj <NvChuongTrinhKhuyenMai>();

            try
            {
                NvChuongTrinhKhuyenMai item = _service.InsertPhieu(instance);
                _service.UnitOfWork.Save();
                result.Data   = item;
                result.Status = true;
                return(CreatedAtRoute("DefaultApi", new { controller = this, id = instance.Id }, result));
            }
            catch (Exception e)
            {
                result.Status  = false;
                result.Message = e.Message;
                return(Ok(result));
            }
        }
        public async Task <IHttpActionResult> GetDetails(string id)
        {
            TransferObj <NvKhuyenMaiTichDiemVm.Dto> result = new TransferObj <NvKhuyenMaiTichDiemVm.Dto>();

            NvKhuyenMaiTichDiemVm.Dto temp = new NvKhuyenMaiTichDiemVm.Dto();

            NvChuongTrinhKhuyenMai phieu = _service.FindById(id);

            if (phieu != null)
            {
                temp = Mapper.Map <NvChuongTrinhKhuyenMai, NvKhuyenMaiTichDiemVm.Dto>(phieu);
                DbSet <NvChuongTrinhKhuyenMaiChiTiet> tb_ChuongTrinhKhuyenMaiChiTiet = _service.UnitOfWork.Repository <NvChuongTrinhKhuyenMaiChiTiet>().DbSet;

                List <NvChuongTrinhKhuyenMaiChiTiet> chiTietChuongTrinhKhuyenMai = tb_ChuongTrinhKhuyenMaiChiTiet.Where(x => x.MaChuongTrinh == phieu.MaChuongTrinh).ToList();
                temp.DataDetails = Mapper.Map <List <NvChuongTrinhKhuyenMaiChiTiet>, List <NvKhuyenMaiTichDiemVm.DtoDetail> >(chiTietChuongTrinhKhuyenMai);

                result.Data   = temp;
                result.Status = true;
                return(Ok(result));
            }
            return(NotFound());
        }