Пример #1
0
        public IHttpActionResult VanSalesDailyReport(VanSalesDailyCashSync model)
        {
            var serialNumber = model.SerialNumber.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNumber);

            if (terminal == null)
            {
                return(Unauthorized());
            }

            var TransactionLog = TerminalServices.CheckTransactionLog(model.TransactionLogId, terminal.TerminalId);

            if (TransactionLog == true)
            {
                return(Conflict());
            }

            model.TenantId = terminal.TenantId;


            var result = _vanSalesService.SaveVanSalesDailyReport(model);

            var terminalLog = TerminalServices.CreateTerminalLog(DateTime.UtcNow, terminal.TenantId, 0, terminal.TerminalId, TerminalLogTypeEnum.VanSalesDailyReport).TerminalLogId;

            var report = Mapper.Map <VanSalesDailyCash, VanSalesDailyCashSync>(result);

            report.UserId       = model.UserId;
            report.SerialNumber = model.SerialNumber;
            report.TerminalId   = model.TerminalId;
            return(Ok(report));
        }
Пример #2
0
        public VanSalesDailyCash SaveVanSalesDailyReport(VanSalesDailyCashSync vanSalesCashReport)
        {
            var model = Mapper.Map <VanSalesDailyCashSync, VanSalesDailyCash>(vanSalesCashReport);

            model.UpdateCreatedInfo(vanSalesCashReport.UserId);
            _currentDbContext.VanSalesDailyCashes.Add(model);
            _currentDbContext.SaveChanges();
            model.SalesManUserId = vanSalesCashReport.UserId;
            foreach (var id in vanSalesCashReport.OrderIds)
            {
                var order = _currentDbContext.Order.Where(x => x.OrderToken == id).FirstOrDefault();
                if (order != null)
                {
                    order.DateUpdated         = DateTime.UtcNow;
                    order.VanSalesDailyCashId = model.VanSalesDailyCashId;
                    order.EndOfDayGenerated   = true;
                }
            }

            _currentDbContext.SaveChanges();
            return(model);
        }