Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            Console.CursorVisible   = false;
            Console.Title           = Resources.WindowTitle;
            Console.BackgroundColor = ConsoleColor.DarkCyan;
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.Clear();
            Console.WriteLine(Resources.Header);

            ChannelServices.RegisterChannel(new TcpChannel(new Hashtable
            {
                { "port", WarehouseCommon.BookstorePort }
            }, new BinaryClientFormatterSinkProvider(), new BinaryServerFormatterSinkProvider
            {
                TypeFilterLevel = TypeFilterLevel.Full
            }), false);

            try
            {
                Bookstore.Open();
                RemotingConfiguration.RegisterActivatedServiceType(typeof(IBookstoreRemoting));
                RemotingServices.Marshal(new BookstoreRemoting(), WarehouseCommon.BookstoreEndpoint);
                LogMessage("IStoreService running on port {0:D}...", Bookstore.BaseAddresses.FirstOrDefault()?.Port);
                Webstore.Open();
                LogMessage("IWebstoreService running on port {0:D}...", Webstore.BaseAddresses.FirstOrDefault()?.Port);
                LogMessage("Press <any> key to close!");
                Console.ReadKey(true);
                Bookstore.Close();
                Webstore.Close();
            }
            catch (Exception ex)
            {
                LogException(ex);
                Console.BackgroundColor = ConsoleColor.DarkRed;
                Console.ForegroundColor = ConsoleColor.Red;
                LogMessage(Resources.ExceptionCaught);
            }
        }
Beispiel #2
0
        public string insertCustomer(Webstore.Models.customer customer)
        {
            try
            {
                using (var db = new DataClassesDataContext())
                {
                    var zip = from z in db.cities
                              where z.zipcode == customer.zipcode
                              select z;

                    if (zip.Count() == 0)
                    {
                        return "This is not a norwegian zipcode";
                    }
                    db.customers.InsertOnSubmit(customer);
                    db.SubmitChanges();
                    return "You've been registered! You will now be redirected back to the store";
                }
            }
            catch
            {
                return "Something went wrong. Try again later.";
            }
        }