void ParseClientOrderCommand(Command command)
 {
     if (command.Entity as ClientOrder == null)
         throw new ArgumentException("Command has incorrect entity type. The entity should be ClientOrder", "command");
     switch (command.CommandType)
     {
         case CommandType.Create:
             {
                 Order tmpOrder = EntitiesTranslator.TranslateToOrder((ClientOrder)command.Entity,user);
                 tmpOrder.Items.Clear();
                 ClientOrder newOrder = EntitiesTranslator.TranslateToClientOrder(contract.SaveNewOrder(tmpOrder));
                 ((ClientOrder)command.Entity).Id = newOrder.Id;
                 ((ClientOrder)command.Entity).PlacingDate = newOrder.PlacingDate;
                 ((ClientOrder)command.Entity).Status = newOrder.Status;
                 if (order == null)
                     order = newOrder;
                 return;
             }
         case CommandType.Delete:
             {
                 Order tmpOrder = EntitiesTranslator.TranslateToOrder((ClientOrder)command.Entity,user);
                 tmpOrder.Items.Clear();
                 contract.RemoveOrder(tmpOrder);
                 return;
             }
         case CommandType.Update:
             {
                 if (command.FieldName == "Status")
                 {
                     contract.ChangeOrderStatus(command.Entity.Id, (Status)command.Value);
                 }
                 else
                 {
                     throw new UnknownFieldNameException("Parser cannot recognize the field " + command.FieldName);
                 }
                 return;
             }
     }
 }
 void ParseClientOrderItemCommand(Command command, ClientOrder order)
 {
     if (command.Entity as ClientOrderItem == null)
         throw new ArgumentException("Command has incorrect entity type. The entity should be ClientOrderItem", "command");
     switch (command.CommandType)
     {
         case CommandType.Create:
             {
                 BindingList<ClientOrderItem> products = order.Products;
                 order.Products.Clear();
                 contract.SaveNewOrderItem(EntitiesTranslator.TranslateToOrderItem((ClientOrderItem)command.Entity, EntitiesTranslator.TranslateToOrder(order,user)));
                 order.Products = products;
                 return;
             }
         case CommandType.Delete:
             {
                 contract.RemoveOrderItem(contract.GetOrderItem(order.Id, command.Entity.Id));
                 return;
             }
         case CommandType.Update:
             {
                 if (command.FieldName == "Count")
                 {
                     contract.ChangeOrderItemCount(contract.GetOrderItem(order.Id, command.Entity.Id).Id, (int)command.Value);
                 }
                 return;
             }
     }
 }