private static IEnumerable<Link> GetLinks(Order order, string baseAddress)
        {
            var baseUri = new UriSegment(baseAddress);
              var linker = new ResourceLinker(baseAddress);

              var get = new Link(linker.BuildUriString(OrderResourceHandler.Path,
                                               OrderResourceHandler.SlashOrderId,
                                               new {orderId = order.Id}),
                         baseUri + "docs/order-get.htm",
                         MediaTypes.Default);

              var update = new Link(linker.BuildUriString(OrderResourceHandler.Path,
                                                  OrderResourceHandler.SlashOrderId,
                                                  new {orderId = order.Id}),
                            baseUri + "docs/order-update.htm",
                            MediaTypes.Default);

              var cancel = new Link(linker.BuildUriString(OrderResourceHandler.Path,
                                                  OrderResourceHandler.SlashOrderId,
                                                  new {orderId = order.Id}),
                            baseUri + "docs/order-cancel.htm",
                            MediaTypes.Default);

              var pay = new Link(linker.BuildUriString(OrderResourceHandler.Path,
                                               OrderResourceHandler.PaymentPath,
                                               new {orderId = order.Id}),
                         baseUri + "docs/order-pay.htm",
                         MediaTypes.Default);

              var receipt = new Link(linker.BuildUriString(OrderResourceHandler.Path,
                                                   OrderResourceHandler.ReceiptPath,
                                                   new {orderId = order.Id}),
                             baseUri + "docs/receipt-coffee.htm",
                             MediaTypes.Default);

              switch (order.Status)
              {
            case OrderStatus.Unpaid:
              yield return get;
              yield return update;
              yield return cancel;
              yield return pay;
              break;
            case OrderStatus.Paid:
            case OrderStatus.Delivered:
              yield return get;
              break;
            case OrderStatus.Ready:
              yield return receipt;
              break;
            case OrderStatus.Canceled:
              yield break;
            default:
              yield break;
              }
        }
Esempio n. 2
0
 public LinkModel(Domain.Link link)
 {
     Id     = link.Id;
     UserId = link.User.Id;
     User   = link.User.IsPopulated()
         ? new UserModel(link.User.Model)
         : null;
     Title     = link.Title.Value;
     Subtitle  = link.Subtitle.Value;
     IconName  = link.IconName.Value;
     Href      = link.Href.Value;
     CreatedAt = link.CreatedAt;
 }
        private static IEnumerable<Link> GetLinks(Order order, ResourceLinker linker, NancyContext context)
        {
            var get = new Link(
            linker.BuildUriString(context, "ReadOrder", new {orderId = order.Id}),
            context.Request.BaseUri() + "/docs/order-get.htm",
            MediaTypes.Default);

              var update = new Link(
            linker.BuildUriString(context, "UpdateOrder", new { orderId = order.Id}),
            context.Request.BaseUri() + "/docs/order-update.htm",
            MediaTypes.Default);

              var cancel = new Link(
            linker.BuildUriString(context, "CancelOrder", new { orderId = order.Id}),
            context.Request.BaseUri() + "/docs/order-cancel.htm",
            MediaTypes.Default);

              var pay = new Link(linker.BuildUriString(context, "PayOrder", new {orderId = order.Id}),
            context.Request.BaseUri() + "/docs/order-pay.htm",
            MediaTypes.Default);

              switch (order.Status)
              {
            case OrderStatus.Unpaid:
              yield return get;
              yield return update;
              yield return cancel;
              yield return pay;
              break;
            case OrderStatus.Paid:
            case OrderStatus.Delivered:
              yield return get;
              break;
            case OrderStatus.Ready:
              break;
            case OrderStatus.Canceled:
              yield break;
            default:
              yield break;
              }
        }
        private void Init(int inputsCount, int neuronsCount)
        {
            foreach (Neuron neuron in _neurons)
            {
                neuron.IncomingLinks = new Link[inputsCount];
            }

            Random rnd = new Random(0);
            for (int i = 0; i < inputsCount; i++)
            {
                Link[] outgoingLinks = new Link[neuronsCount];
                _inputs[i].OutgoingLinks = outgoingLinks;
                for (int j = 0; j < neuronsCount; j++)
                {
                    outgoingLinks[j] = new Link();
                    outgoingLinks[j].Neuron = _neurons[j];
                    outgoingLinks[j].Weight = rnd.NextDouble()/1000;
                    _neurons[j].IncomingLinks[i] = outgoingLinks[j];
                }
            }
        }