예제 #1
0
        public async Task <IActionResult> UpdateStatus(QuanLyDonGiaNhuanBut inputModel)
        {
            try
            {
                await HttpHelper.PostData <QuanLyDonGiaNhuanBut>(inputModel, $"{_domain}/api/quan-ly-nhuan-but/update-status");

                return(Json(new { Result = true, Message = "Cập nhật dữ liệu thành công" }));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = false, Message = ex.Message }));
            }
        }
        public async Task <IActionResult> Create([FromBody] QuanLyDonGiaNhuanBut inputModel)
        {
            try
            {
                await _quanLyDonGiaNhuanButManager.Create(inputModel);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
        public async Task Update(QuanLyDonGiaNhuanBut inputModel)
        {
            try
            {
                await _unitOfWork.QuanLyDonGiaNhuanButRepository.Update(inputModel);

                await _unitOfWork.SaveChange();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public async Task Create(QuanLyDonGiaNhuanBut inputModel)
        {
            try
            {
                var result = await _unitOfWork.QuanLyDonGiaNhuanButRepository.Add(inputModel);

                await _unitOfWork.SaveChange();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public async Task <IActionResult> Update([FromBody] QuanLyDonGiaNhuanBut inputModel)
        {
            try
            {
                var data = await _quanLyDonGiaNhuanButManager.Find_By_Id(inputModel.Id);

                if (data == null)
                {
                    throw new Exception($"{MessageConst.DATA_NOT_FOUND}");
                }
                await _quanLyDonGiaNhuanButManager.Update(inputModel);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
예제 #6
0
        public async Task <IActionResult> Create_Or_Update(QuanLyDonGiaNhuanBut inputModel)
        {
            try
            {
                if (inputModel.Id == 0)
                {
                    await HttpHelper.PostData <QuanLyDonGiaNhuanBut>(inputModel, $"{_domain}/api/quan-ly-nhuan-but/create");

                    return(Json(new { Result = true, Message = "Thêm mới dữ liệu thành công" }));
                }
                else
                {
                    await HttpHelper.PostData <QuanLyDonGiaNhuanBut>(inputModel, $"{_domain}/api/quan-ly-nhuan-but/update");

                    return(Json(new { Result = true, Message = "Cập nhật dữ liệu thành công" }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { Result = false, Message = ex.Message }));
            }
        }
예제 #7
0
        public async Task <IActionResult> Delete(QuanLyDonGiaNhuanBut inputmodel)
        {
            try
            {
                if (inputmodel.Status == (byte)StatusEnum.Removed)
                {
                    await HttpHelper.PostData <QuanLyDonGiaNhuanBut>(inputmodel, $"{_domain}/api/quan-ly-nhuan-but/delete");

                    return(Json(new { Result = true }));
                }
                else
                {
                    await HttpHelper.PostData <QuanLyDonGiaNhuanBut>(inputmodel, $"{_domain}/api/quan-ly-nhuan-but/update-status");

                    return(Json(new { Result = true }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { Result = false, Message = ex.Message }));
            }
        }