private void AddOrderStatus(IGEN_IGENITYORDER order, string status, DateTime date) { order.IGEN_ORDERSTATUS.Add(new IGEN_ORDERSTATUS { IGEN_IGENITYORDER = order, ORDERSTATUSCODES_ID = _orderStatusCodesList[status], STATUSDATE = date }); }
/// <summary> /// </summary> /// <param name="order"></param> /// <returns></returns> public int AddGenomicsOrder(GenomicsOrder order) { var custId = order.CustId.SafeToString(); var genomicsCustomer = _allRepositories.CustomRepository.FindBy(x => x.SHIPTO == custId).ToList() .FirstOrDefault(); var genomicsUser = _allRepositories.UserRepository.FindBy(x => x.USER_ID == order.UserId).FirstOrDefault(); var genomicsLab = _allRepositories.LabRepository.FindBy(x => x.LAB_ID == order.LabId).FirstOrDefault(); ValidationObjects(order, genomicsCustomer, genomicsUser, genomicsLab); var samples = MakeGenomicsSamples(order, genomicsCustomer); var igenityOrder = new IGEN_IGENITYORDER { COMPSALESREP_ID = null, DECELERATOR = false, CHECKAMOUNT = null, CHECKNUMBER = null, PRIORITY = 2, ORDERTYPE = $"Commercial {order.OrderOrigin.SafeToString()}", PAYMENTTYPE = "No Charge", PAYMENTREFERENCE = null, COMMENTS = order.Notes, REDOORDERID = null, EMAILRECEIVED_DATE = null, SEASON_ID = null, IGEN_CUSTOMER = genomicsCustomer, IGEN_USER = genomicsUser, IGEN_LAB = genomicsLab }; if (!order.OrderDate.HasValue) { order.OrderDate = DateTime.Now; } AddOrderStatus(igenityOrder, "Order Received", order.OrderDate.Value); foreach (var sample in samples) { igenityOrder.IGEN_SAMPLE.Add(sample); } _allRepositories.IgenitiyOrderRepository.Add(igenityOrder); _allRepositories.Save(); _logger.Info( $"Genomics Order added Genomics Order Id: {igenityOrder.IGENITYORDER_ID}"); return(igenityOrder.IGENITYORDER_ID); }