Exemplo n.º 1
0
        /// <summary>
        /// Сохранение Первоначального акта ордера
        /// </summary>
        public InitialOrder AddInitialOrder(IEnumerable <KeyValuePair <Product, double> > quotationList,
                                            BaseEntityObject parent,
                                            DateTime effDate,
                                            DeferredCategory category,
                                            out string message)
        {
            if (parent == null)
            {
                message = "Not set parent." +
                          "\nFailed to create empty Initial Order";
                return(null);
            }

            if (!(parent is Aircraft) && !(parent is Operator) && !(parent is Store))
            {
                message = "Parent must be Aircraft or Store or Operator." +
                          "\nFailed to create empty Initial Order";
                return(null);
            }

            if (quotationList == null)
            {
                message = "Selected tasks not have a accessories." +
                          "\nFailed to create empty Initial Order";
                return(null);
            }

            var rqst = new InitialOrder
            {
                Description    = "",
                Status         = WorkPackageStatus.Opened,
                Author         = _casEnvironment.Operators[0].Name,
                OpeningDate    = DateTime.Today,
                PublishingDate = new DateTime(1852, 01, 01),
                ClosingDate    = new DateTime(1852, 01, 01),
                Remarks        = "",
                ParentType     = parent.SmartCoreObjectType,
                ParentId       = parent.ItemId,
                Title          = parent + "-IO-" + DateTime.Now
            };

            _newKeeper.Save(rqst);

            #region Формирование записей рабочего пакета
            foreach (var item in quotationList)
            {
                Product product  = item.Key;
                double  quantity = item.Value;

                var record =
                    rqst.PackageRecords.FirstOrDefault(r => r.PackageItemType == product.SmartCoreObjectType &&
                                                       r.PackageItemId == product.ItemId);
                if (record != null)
                {
                    record.Quantity += item.Value;
                }
                else
                {
                    record = new InitialOrderRecord(rqst.ItemId,
                                                    product,
                                                    quantity,
                                                    parent,
                                                    effDate,
                                                    ComponentStatus.New | ComponentStatus.Overhaul | ComponentStatus.Repair | ComponentStatus.Serviceable,
                                                    null,
                                                    category);
                    rqst.PackageRecords.Add(record);
                }
            }
            #endregion

            #region Сохранение рабочего пакета и его записей

            foreach (var item in rqst.PackageRecords)
            {
                item.ParentPackageId = rqst.ItemId;
                _newKeeper.Save(item);
            }

            message = "Items added successfully";

            #endregion

            return(rqst);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Создает запись  без дополнительной информации
 /// </summary>
 public IORQORRelation(InitialOrderRecord initialOrderRecord, RequestForQuotationRecord requestForQuotationRecord) : this()
 {
     _initialOrderRecord        = initialOrderRecord;
     _requestForQuotationRecord = requestForQuotationRecord;
 }