Example #1
0
        public void Delivered(int orderId, int softMealId, int employeeId)
        {
            if (orderId > 0)
            {
                var log = new DeliveryLog
                {
                    Date        = DateTime.Now,
                    Status      = 4,
                    Description = "Подигната нарачка",
                    EmployeeId  = employeeId,
                    OrderId     = orderId,
                    SoftMealId  = 0
                };
                _orderRepository.AddDeliveryLog(log);

                _orderRepository.Delivered(orderId);
            }
            else
            {
                var log = new DeliveryLog
                {
                    Date        = DateTime.Now,
                    Status      = 5,
                    Description = "Подигнат сув оброк",
                    EmployeeId  = employeeId,
                    OrderId     = 0,
                    SoftMealId  = softMealId
                };
                _orderRepository.AddDeliveryLog(log);

                _orderRepository.DeliveredSoftMeal(softMealId);
            }
        }
Example #2
0
        public async Task <IHttpActionResult> GetDeliveryLog(int id)
        {
            DeliveryLog deliveryLog = await db.DeliveryLogs.FindAsync(id);

            if (deliveryLog == null)
            {
                return(NotFound());
            }

            return(Ok(deliveryLog));
        }
Example #3
0
        public async Task <IHttpActionResult> PostDeliveryLog(DeliveryLog deliveryLog)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.DeliveryLogs.Add(deliveryLog);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = deliveryLog.Id }, deliveryLog));
        }
Example #4
0
        /// <summary>
        /// Save the delivery change history log into deliveryLog
        /// </summary>
        /// <param name="db">current db</param>
        /// <param name="status1">from status</param>
        /// <param name="status2">to status</param>
        /// <returns>saved delivery log id</returns>
        public int LogDeliveryChange(DataContext db, int deliveryID, int status1, int status2)
        {
            DeliveryLog dyLog = new DeliveryLog();

            dyLog.DeliveryID       = deliveryID;
            dyLog.Status1          = status1;
            dyLog.Status2          = status2;
            dyLog.UpdateDate       = CurrentUpdateDate;
            dyLog.UpdateEmployeeID = CurrentEmployee.ID;
            db.DeliveryLogsDB.Add(dyLog);
            db.SaveChanges();
            return(dyLog.ID);
        }
Example #5
0
        public async Task <IHttpActionResult> DeleteDeliveryLog(int id)
        {
            DeliveryLog deliveryLog = await db.DeliveryLogs.FindAsync(id);

            if (deliveryLog == null)
            {
                return(NotFound());
            }

            db.DeliveryLogs.Remove(deliveryLog);
            await db.SaveChangesAsync();

            return(Ok(deliveryLog));
        }
        public bool AddInventory(DeliveryLogVM obj)
        {
            bool        result   = false;
            DeliveryLog delivery = new DeliveryLog();
            List <DeliverylogDetail>      details       = new List <DeliverylogDetail>();
            List <RunningInventory>       runinvee      = new List <RunningInventory>();
            List <BranchInventorySummary> branchsummary = new List <BranchInventorySummary>();

            foreach (var a in obj.DeliverylogDetails)
            {
                if (!_InventoryhelperRepo.CheckIfIsExist(obj.BranchId, a.ProductId))
                {
                    details.Add(new DeliverylogDetail
                    {
                        Good       = a.Good,
                        Bad        = a.Bad,
                        DateExpiry = a.DateExpiry,
                        ProductId  = a.ProductId
                    });

                    branchsummary.Add(new BranchInventorySummary
                    {
                        BranchId        = obj.BranchId,
                        ProductId       = a.ProductId,
                        TotalInventory  = a.Good,
                        ProductReleased = 0,
                        TotalIn         = a.Good,
                        TotalOut        = 0
                    });

                    runinvee.Add(new RunningInventory
                    {
                        ProductId = a.ProductId,
                        Bottles   = a.Good
                    });
                }
                else
                {
                    var currentdata = _branchInventorySumRepo.GetExistingBranchInveSum(obj.BranchId, a.ProductId).FirstOrDefault();

                    currentdata.TotalInventory += a.Good;
                    currentdata.TotalIn        += a.Good;
                    productRemaining            = currentdata.ProductOnHand.Value;
                    newProductStock             = currentdata.ProductOnHand.Value + a.Good;

                    var updatebranch = this._branchInventorySumRepo.Update(currentdata);
                    //if(updatebranch.)

                    details.Add(new DeliverylogDetail
                    {
                        Good = a.Good,
                        Bad  = a.Bad,
                        //DateExpiry = a.DateExpiry,
                        ProductId = a.ProductId
                    });

                    runinvee.Add(new RunningInventory
                    {
                        ProductId = a.ProductId,
                        Bottles   = a.Good
                    });
                }
            }


            delivery.BranchId           = obj.BranchId;
            delivery.ReceivedBy         = obj.ReceivedBy;
            delivery.RunningInventories = runinvee;
            delivery.DeliverylogDetails = details;
            delivery.BatchNo            = obj.BatchNo;



            var data = this._deliverylogrepo.Add(delivery);

            if (data != null)
            {
                result = true;
            }
            return(result);
        }
Example #7
0
        public OrderDeliveryDTO GetByRfid(string rfid, DateTime date, int shift)
        {
            var order = _orderRepository.GetByRfid(rfid, date, shift);

            if (order != null)
            {
                if (!order.IsDelivered)
                {
                    var log = new DeliveryLog
                    {
                        Date        = DateTime.Now,
                        Status      = 0,
                        Description = "Побарана нарачка",
                        EmployeeId  = order.EmployeeId,
                        OrderId     = order.Id,
                        SoftMealId  = 0
                    };
                    _orderRepository.AddDeliveryLog(log);

                    return(new OrderDeliveryDTO
                    {
                        OrderId = order.Id,
                        SoftMealId = 0,
                        IsDelivered = order.IsDelivered,
                        ImageBase64 = order.Plan.Meal.MealImage.ImageBase64,
                        Name = order.Plan.Meal.Name,
                        NameForeign = order.Plan.Meal.NameForeign
                    });
                }
                else
                {
                    var log = new DeliveryLog
                    {
                        Date        = DateTime.Now,
                        Status      = 1,
                        Description = "Веќе е подигната нарачка во оваа смена",
                        EmployeeId  = order.EmployeeId,
                        OrderId     = order.Id,
                        SoftMealId  = 0
                    };
                    _orderRepository.AddDeliveryLog(log);

                    throw new Exception("Веќе е подигната нарачка во оваа смена");
                }
            }
            else
            {
                var softMeal = _orderRepository.GetSoftMeal(rfid, date, shift);
                if (softMeal != null)
                {
                    if (!softMeal.IsDelivered)
                    {
                        var log = new DeliveryLog
                        {
                            Date        = DateTime.Now,
                            Status      = 2,
                            Description = "Побаран сув оброк",
                            EmployeeId  = softMeal.EmployeeId,
                            OrderId     = 0,
                            SoftMealId  = softMeal.Id
                        };
                        _orderRepository.AddDeliveryLog(log);

                        return(new OrderDeliveryDTO
                        {
                            OrderId = 0,
                            SoftMealId = softMeal.Id,
                            IsDelivered = softMeal.IsDelivered,
                            ImageBase64 = softMeal.SoftMealDetail.ImageBase64,
                            Name = softMeal.SoftMealDetail.Name,
                            NameForeign = softMeal.SoftMealDetail.NameForeign
                        });
                    }
                    else
                    {
                        var log = new DeliveryLog
                        {
                            Date        = DateTime.Now,
                            Status      = 3,
                            Description = "Веќе е подигнат сув оброк во оваа смена",
                            EmployeeId  = softMeal.EmployeeId,
                            OrderId     = 0,
                            SoftMealId  = softMeal.Id
                        };
                        _orderRepository.AddDeliveryLog(log);

                        throw new Exception("Веќе е подигнат сув оброк во оваа смена");
                    }
                }
                else
                {
                    var employee   = _employeeRepository.GetByRfid(rfid);
                    var softMealDb = new SoftMeal
                    {
                        Date             = date,
                        EmployeeId       = employee.Id,
                        IsDelivered      = false,
                        Shift            = shift,
                        SoftMealDetailId = 1
                    };
                    _orderRepository.AddSoftMeal(softMealDb);

                    var log = new DeliveryLog
                    {
                        Date        = DateTime.Now,
                        Status      = 2,
                        Description = "Побаран сув оброк",
                        EmployeeId  = softMealDb.EmployeeId,
                        OrderId     = 0,
                        SoftMealId  = softMealDb.Id
                    };
                    _orderRepository.AddDeliveryLog(log);

                    var softMealDetail = _orderRepository.GetSoftMealDetail(1);
                    return(new OrderDeliveryDTO
                    {
                        OrderId = 0,
                        SoftMealId = softMealDb.Id,
                        IsDelivered = softMealDb.IsDelivered,
                        ImageBase64 = softMealDetail.ImageBase64,
                        Name = softMealDetail.Name,
                        NameForeign = softMealDetail.NameForeign
                    });
                }
            }
        }
Example #8
0
 public void AddDeliveryLog(DeliveryLog deliveryLog)
 {
     _context.DeliveryLogs.Add(deliveryLog);
     _context.SaveChanges();
 }
Example #9
0
        /// <summary>
        /// 记录Dn过站记录
        /// </summary>
        /// <param name="log">Dn过站记录</param>
        public void AddLog(DeliveryLog log)
        {
            if (log == null)
                return;

            lock (_syncObj_logs)
            {
                if (this._logs == null)
                {
                    this._logs = new List<DeliveryLog>();
                }

                //object naught = this.ProductLogs;
                if (this._logs.Contains(log))
                    return;

                log.Tracker = this._tracker.Merge(log.Tracker);
                this._logs.Add(log);
                this._tracker.MarkAsAdded(log);
                this._tracker.MarkAsModified(this);

                LoggingInfoFormat("Tracker Content: {0}", this._tracker.ToString());
            }
        }