示例#1
0
        public void Update(ChangeOrderModel model)
        {
            if (Status != OrderStatus.ResponseAccepted)
            {
                throw new InvalidOperationException($"Bokningen {OrderId} har fel status {Status} för att kunna uppdateras.");
            }
            if (model == null)
            {
                throw new InvalidOperationException($"Hittar inga ändringar för bokning {OrderId}.");
            }
            List <OrderAttachmentHistoryEntry> orderAttachmentHistories = new List <OrderAttachmentHistoryEntry>();
            List <OrderHistoryEntry>           orderHistories           = new List <OrderHistoryEntry>();

            if (model.OrderChangeLogType == OrderChangeLogType.Attachment || model.OrderChangeLogType == OrderChangeLogType.AttachmentAndOrderInformationFields)
            {
                orderAttachmentHistories = ChangeAttachments(model.Attachments);
            }
            if (model.OrderChangeLogType == OrderChangeLogType.OrderInformationFields || model.OrderChangeLogType == OrderChangeLogType.AttachmentAndOrderInformationFields)
            {
                orderHistories = ChangeOrderFields(model);
            }
            OrderChangeLogEntries.Add(new OrderChangeLogEntry
            {
                LoggedAt                      = model.UpdatedAt,
                UpdatedByUserId               = model.UpdatedBy,
                UpdatedByImpersonatorId       = model.ImpersonatedUpdatedBy,
                OrderChangeLogType            = model.OrderChangeLogType,
                OrderAttachmentHistoryEntries = orderAttachmentHistories,
                OrderHistories                = orderHistories,
                BrokerId                      = model.BrokerId
            });
        }
示例#2
0
 public void ChangeContactPerson(DateTimeOffset changedAt, int userId, int?impersonatingUserId, AspNetUser newContactPerson)
 {
     if (newContactPerson != null && newContactPerson.CustomerOrganisationId != CustomerOrganisationId)
     {
         throw new InvalidOperationException($"Cannot assign User {newContactPerson.Id} as contact person on Order {OrderId}, since this user belongs to CustomerOrganization {newContactPerson.CustomerOrganisationId}");
     }
     if (Status == OrderStatus.CancelledByCreator || Status == OrderStatus.CancelledByBroker || Status == OrderStatus.NoBrokerAcceptedOrder || Status == OrderStatus.ResponseNotAnsweredByCreator)
     {
         throw new InvalidOperationException($"Order {OrderId} is {Status}. Can't change contact person for orders with this status.");
     }
     OrderChangeLogEntries.Add(new OrderChangeLogEntry
     {
         LoggedAt                  = changedAt,
         UpdatedByUserId           = userId,
         UpdatedByImpersonatorId   = impersonatingUserId,
         OrderChangeLogType        = OrderChangeLogType.ContactPerson,
         OrderContactPersonHistory = new OrderContactPersonHistory {
             PreviousContactPersonId = ContactPersonId
         }
     });
     ContactPersonUser = newContactPerson;
 }