Esempio n. 1
0
        public async Task <IHttpActionResult> PostUpdateGiaVon(MdPeriod instance)
        {
            try
            {
                var exsist = _service.Find(instance);
                if (exsist == null)
                {
                    return(NotFound());
                }
                var processName = CodeProcess.CAPNHATGIAVON.ToString();
                var unitCode    = _service.GetCurrentUnitCode();
                var process     = _service.UnitOfWork.Repository <MdMonitorProcess>().DbSet.FirstOrDefault(x => x.ProcessCode == processName && x.UnitCode == unitCode && x.State == ProcessState.IsRunning);
                if (process != null)
                {
                    process.State = ProcessState.IsRunning;
                    return(BadRequest("Đang cập nhật giá vốn"));
                }
                if (!_service.UpDateGiaVon(instance))
                {
                    return(BadRequest("Chưa thể cập nhật được giá vốn"));
                }

                return(Ok());
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
        }
Esempio n. 2
0
        public async Task <IHttpActionResult> UpdateGiaVon(ParameterInventory para)
        {
            var unitCode = _servicePeriod.GetCurrentUnitCode();
            var period   = _service.UnitOfWork.Repository <MdPeriod>().DbSet.Where(x => x.ToDate.Date == para.ToDate.Date).FirstOrDefault();

            if (period != null)
            {
                try
                {
                    _servicePeriod.UpDateGiaVon(period);
                    return(Ok(true));
                }
                catch (Exception)
                {
                    return(InternalServerError());
                }
            }
            return(Ok(false));
        }