Beispiel #1
0
        public void RefreshStockItems()
        {
            Modified = false;
            StockItemsCollection.Clear();
            RemovedStockItemsList.Clear();

            Worker.EnqueueTask(new WorkerTask((args) =>
            {
                try
                {
                    using (var proxy = new WorkChannel())
                    {
                        return proxy.GetIngredients(new EmptyRequest
                        {
                            Login = ClientConfig.CurrentUser.Email,
                            Password = ClientConfig.CurrentUser.Password
                        });
                    }
                }
                catch (Exception exc)
                {
                    Console.WriteLine(exc.Message);
                    return exc;
                }
            }, PostData, null));
        }
Beispiel #2
0
 public void RefreshComplaints()
 {
     ComplaintsCollection.Clear();
     Worker.EnqueueTask(new WorkerTask((a) =>
         {
             try
             {
                 using (var proxy = new WorkChannel())
                 {
                     var res = proxy.GetComplaints(new EmptyRequest
                         {
                             Login = ClientConfig.CurrentUser.Email,
                             Password = ClientConfig.CurrentUser.Password
                         });
                     return res.Data;
                 }
             }
             catch (Exception e)
             {
                 return e;
             }
         }, (s, e) =>
         {
             if (e.Result is Exception)
             {
                 Utils.HandleException(e.Result as Exception);
                 return;
             }
             var list = e.Result as List<ComplaintDTO>;
             foreach (var i in list)
                 ComplaintsCollection.Add(i);
         }, null));
 }
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     worker.EnqueueTask(new Workers.WorkerTask((args) =>
         {
             var list = args[0] as List<OrderSuppliesDTO>;
             try
             {
                 using (var proxy = new WorkChannel())
                 {
                     return proxy.OrderSupplies(new UpdateRequest<List<OrderSuppliesDTO>>()
                     {
                         Data = list,
                         Login = ClientConfig.CurrentUser.Email,
                         Password = ClientConfig.CurrentUser.Password
                     });
                 }
             }
             catch(Exception exc)
             {
                 Console.WriteLine(exc.Message);
                 return exc;
             }
         },
         (s,ex) =>
         {
             if (ex.Result is Exception)
             {
                 Utils.HandleException(ex.Result as Exception);
                 return;
             }
             var res = ex.Result as ListResponse<OrderSuppliesDTO>;
             if (res==null)
             {
                 Utils.showError(Utils.Messages.ORDER_FAILURE);
                 return;
             }
             Data.Clear();
             foreach(var item in res.Data)
                 Data.Add(item);
         }, Data.ToList()));
 }
 internal void SetOrderInRealization(OrdersRow o)
 {
     Worker.EnqueueTask(new WorkerTask((args) =>
     {
         try
         {
             using (var proxy = new WorkChannel())
             {
                 OrderDTO order = o.Order.Clone();
                 order.State.StateValue = State.IN_REALISATION;
                 return proxy.SetOrderState(new UpdateRequest<OrderDTO>
                 {
                     Data = order,
                     Login = ClientConfig.CurrentUser.Email,
                     Password = ClientConfig.CurrentUser.Password
                 });
             }
         }
         catch (Exception e)
         {
             return e;
         }
     }, (a, s) =>
     {
         if (s.Result is Exception)
         {
             Utils.HandleException(s.Result as Exception);
             return;
         }
         var res = s.Result as SingleItemResponse<OrderDTO>;
         if (res == null)
         {
             Utils.showError(Utils.Messages.UNKNOWN_ERROR_FORMAT);
             return;
         }
         o.Order.State = res.Data.State;
         o.Update();
     }));
 }
        internal void RemoveOrder(int orderIndex)
        {
            OrdersRow or = OrdersCollection[orderIndex];
            Worker.EnqueueTask(new WorkerTask((args) =>
            {
                try
                {
                    using (var proxy = new WorkChannel())
                    {
                        proxy.RemoveOrder(new UpdateOrRemoveRequest<OrderDTO>
                        {
                            Data = null,
                            DataToRemove = or.Order,
                            Login = ClientConfig.CurrentUser.Email,
                            Password = ClientConfig.CurrentUser.Password
                        });
                    }
                    return true;
                }
                catch(Exception e)
                {
                    return e;
                }
                //using (var db = new PizzaUnitOfWork())
                //{
                //    return db.inTransaction(uof =>
                //    {

                //        Console.WriteLine("Remove order");

                //        Order o = db.Orders.Get(or.Order.OrderID);
                //        db.Orders.Delete(o);
                //        db.Commit();
                //        Console.WriteLine("Order " + or.Order.OrderID + " removed.");
                //        return or;
                //    });
                //}
            },
            (s, a) =>
            {
                if (a.Result is Exception)
                {
                    Utils.HandleException(a.Result as Exception);
                    return;
                }
                if (!((a.Result as bool?)??false))
                {
                    Utils.showError(Utils.Messages.UNKNOWN_ERROR_FORMAT);
                    return;
                }
                RefreshCurrentOrders();
            }));
        }
 //private void SetOrderStateInBackground(OrdersRow or, State state)
 //{
 //    Worker.EnqueueTask(new WorkerTask((args) =>
 //    {
 //        using (var db = new PizzaUnitOfWork())
 //        {
 //            return db.inTransaction(uof =>
 //            {
 //                Console.WriteLine("Set in realisation");
 //                Order o = uof.Db.Orders.Get(or.Order.OrderID);
 //                o.State.StateValue = state.StateValue;
 //                uof.Db.Commit();
 //                Console.WriteLine("Order " + or.Order.OrderID + " state set to IN REALISATION");
 //                return or;
 //            });
 //        }
 //    },
 //    (s, a) =>
 //    {
 //        RefreshCurrentOrders();
 //        //or.Order.State = state;
 //        or.Update();
 //        // TODO zwalone sortowanie po zmianie stanu, nie uaktualnia się
 //    }));
 //}
 public void RefreshCurrentOrders()
 {
     Worker.EnqueueTask(new WorkerTask((args) =>
     {
         try
         {
             using (var proxy = new WorkChannel())
             {
                 return proxy.GetUndoneOrders(new PizzaNetCommon.Requests.EmptyRequest
                 {
                     Login = ClientConfig.CurrentUser.Email,
                     Password = ClientConfig.CurrentUser.Password
                 });
             }
             //using (var db = new PizzaUnitOfWork())
             //{
             //    return db.inTransaction(uof =>
             //    {
             //        Console.WriteLine("Load Orders Start");
             //        var result = uof.Db.Orders.FindAllEagerlyWhere((o) => o.State.StateValue == State.IN_REALISATION || o.State.StateValue == State.NEW);
             //        Console.WriteLine("After query");
             //        return result;
             //    });
             //}
         }
         catch (Exception exc)
         {
             Console.WriteLine(exc);
             return exc;
         }
     }, (s, a) =>
     {
         if (a.Result is Exception)
         {
             Utils.HandleException(a.Result as Exception);
             return;
         }
         ListResponse<OrderDTO> res = a.Result as ListResponse<OrderDTO>;
         if (res == null)
         {
             Utils.showExclamation(Utils.Messages.ORDERS_REFRESH_FAILED);
             return;
         }
         List<OrderDTO> orders = res.Data;
         bool[] current = new bool[orders.Count()];
         foreach (var order in orders)
         {
             OrdersRow row = OrdersCollection.FirstOrDefault(r => { return r.Order.OrderID == order.OrderID; });
             if (row != null) row.Order = order;
             else OrdersCollection.Add(new OrdersRow(order));
         }
     }));
 }
Beispiel #7
0
        internal void RefreshUsers()
        {
            Worker.EnqueueTask(new WorkerTask(args =>
                {
                    try
                    {
                        using (var proxy = new WorkChannel())
                        {
                            return proxy.GetUsers(new EmptyRequest
                            {
                                Login = ClientConfig.CurrentUser.Email,
                                Password = ClientConfig.CurrentUser.Password
                            });
                        }
                    }
                    catch (Exception exc)
                    {
                        Console.WriteLine(exc.Message);
                        return exc;
                    }
                }, (s, e) =>
                    {
                        if( e.Result is Exception)
                        {
                            Utils.HandleException(e.Result as Exception);
                            return;
                        }
                        var result = e.Result as ListResponse<UserDTO>;
                        if (result == null)
                        {
                            Utils.showError(Utils.Messages.UNKNOWN_ERROR_FORMAT);
                            return;
                        }

                        UsersCollection.Clear();
                        foreach (var user in result.Data)
                        {
                            UsersCollection.Add(user);
                        }
                        Modified = false;
                    }, null));
        }
Beispiel #8
0
        internal void SaveChanges()
        {
            Worker.EnqueueTask(new WorkerTask(args =>
                {
                    try
                    {
                        using (var proxy = new WorkChannel())
                        {
                            List<UserDTO> toUpdate = new List<UserDTO>();
                            List<UserDTO> toRemove = new List<UserDTO>();
                            foreach (var user in UsersCollection)
                            {
                                toUpdate.Add(user);
                            }

                            foreach (var user in RemovedUsers)
                            {
                                toRemove.Add(user);
                            }

                            return proxy.UpdateOrRemoveUser(new UpdateOrRemoveRequest<List<UserDTO>>
                            {
                                Data = toUpdate,
                                DataToRemove = toRemove,
                                Login = ClientConfig.CurrentUser.Email,
                                Password = ClientConfig.CurrentUser.Password
                            });
                        }
                    }
                    catch (Exception exc)
                    {
                        return exc;
                    }
                }, (s, e) =>
                    {
                        if (e.Result is Exception)
                        {
                            Utils.HandleException(e.Result as Exception);
                            return;
                        }
                        var result = e.Result as ListResponse<UserDTO>;
                        if (result == null)
                        {
                            Utils.showError(Utils.Messages.UNKNOWN_ERROR_FORMAT);
                            return;
                        }
                        UsersCollection.Clear();
                        RemovedUsers.Clear();
                        foreach (var item in result.Data)
                        {
                            UsersCollection.Add(item);
                        }
                        Modified = false;
                    }, null));
        }
Beispiel #9
0
 internal void SaveChanges()
 {
     Worker.EnqueueTask(new WorkerTask((args) =>
     {
         try
         {
             var list = args[0] as List<StockIngredientDTO>;
             var removeList = args[1] as List<StockIngredientDTO>;
             using (var proxy = new WorkChannel())
             {
                 return proxy.UpdateOrRemoveIngredient(new UpdateOrRemoveRequest<List<StockIngredientDTO>>()
                 {
                     Login = ClientConfig.CurrentUser.Email,
                     Password = ClientConfig.CurrentUser.Password,
                     Data = list,
                     DataToRemove = removeList
                 });
             }
         }
         catch (Exception exc)
         {
             Console.WriteLine(exc.Message);
             return exc;
         }
     }, (s, e) =>
     {
         if (e.Result is Exception)
         {
             Utils.HandleException(e.Result as Exception);
             return;
         }
         var result = e.Result as ListResponse<StockIngredientDTO>;
         if (result == null)
         {
             Utils.showError(Utils.Messages.SAVE_CHANGES_FAILURE);
             return;
         }
         RewriteStockItems(result.Data);
         RemovedStockItemsList.Clear();
         Modified = false;
         ResetIds();
     }, StockItemsCollection.ToList(), RemovedStockItemsList));
 }
 internal void SavePassword()
 {
     if (Password != CurrentPassword)
     {
         Utils.showExclamation(Utils.Messages.INVALID_PASSWORD);
         return;
     }
     if (NewPassword != PasswordRepeated)
     {
         Utils.showExclamation(Utils.Messages.REPEATED_PASSWORD_DIFF);
         return;
     }
     if (Password == string.Empty || Password == null ||
         NewPassword == string.Empty || NewPassword == null)
     {
         Utils.showExclamation(Utils.Messages.PASSWORD_EMPTY);
         return;
     }
     Worker.EnqueueTask(new WorkerTask(args =>
     {
         var user = args[0] as User;
         var newPass = args[1] as string;
         try
         {
             if (user == null)
                 throw new PizzaNetException(Utils.Messages.NO_USER_LOGGED_IN);
             using (var proxy = new WorkChannel())
             {
                 return proxy.UpdateUser(new UpdateRequest<UserDTO>()
                     {
                         Login = user.Email,
                         Password = user.Password,
                         Data = new UserDTO()
                         {
                             UserID = user.UserID,
                             Address = null,
                             Email = user.Email,
                             Name = null,
                             Password = newPass,
                             Phone = -1,
                         }
                     });
             }
         }
         catch (Exception e)
         {
             return e;
         }
     },
         (s, e) =>
         {
             if (e.Result is Exception)
             {
                 Utils.HandleException(e.Result as Exception);
                 return;
             }
             var userRes = e.Result as SingleItemResponse<UserDTO>;
             if (userRes == null || userRes.Data == null)
             {
                 Utils.showError(Utils.Messages.UNKNOWN_ERROR_FORMAT);
                 return;
             }
             User.Password = userRes.Data.Password;
             Password = User.Password;
             CurrentPassword = PasswordRepeated = NewPassword = "";
             ModifiedPasssword = false;
             Utils.showInformation(Utils.Messages.PASSWORD_CHANGED);
         }, ClientConfig.CurrentUser, NewPassword));
 }
 public void Load()
 {
     ModifiedPasssword = ModifiedUserData = false;
     Worker.EnqueueTask(new WorkerTask((args) =>
     {
         var user = args[0] as User;
         try
         {
             if (user == null)
                 throw new PizzaNetException(Utils.Messages.NO_USER_LOGGED_IN);
             using (var proxy = new WorkChannel())
             {
                 return proxy.GetUser(new EmptyRequest { Login = user.Email, Password = user.Password });
             }
         }
         catch (Exception e)
         {
             return e;
         }
     }, (s, args) =>
     {
         if (args.Result is Exception)
         {
             Utils.HandleException(args.Result as Exception);
             return;
         }
         var u = args.Result as SingleItemResponse<UserDTO>;
         if (u == null)
         {
             Utils.showError(String.Format(Utils.Messages.NO_USER_FOUND_FORMAT, ClientConfig.CurrentUser.Email));
             return;
         }
         ClientConfig.CurrentUser.UpdateWithUserDTO(u.Data);
         this.User = ClientConfig.CurrentUser;
         CurrentPassword = PasswordRepeated = NewPassword = "";
         Password = ClientConfig.CurrentUser.Password;
     }, ClientConfig.CurrentUser));
 }
Beispiel #12
0
        internal void Order()
        {
            List<OrderDetailDTO> details = new List<OrderDetailDTO>(OrderedPizzasCollection.Count);
            foreach (var item in OrderedPizzasCollection)
                details.Add(item.OrderDetail);

            Worker.EnqueueTask(new WorkerTask((args) =>
            {
                var det = args[0] as List<OrderDetailDTO>;
                try
                {
                    using (var proxy = new WorkChannel())
                    {
                        proxy.MakeOrder(new UpdateRequest<OrderDTO>
                        {
                            Data = new OrderDTO
                                {
                                    Address = ClientConfig.CurrentUser.Address,
                                    Date = DateTime.Now,
                                    CustomerPhone = ClientConfig.CurrentUser.Phone,
                                    OrderDetailsDTO = det
                                },
                            Login = ClientConfig.CurrentUser.Email,
                            Password = ClientConfig.CurrentUser.Password
                        });
                    }
                    return true;
                }
                catch (Exception e)
                {
                    return e;
                }
            }, (s, args) =>
            {
                if (args.Result is Exception)
                {
                    Utils.HandleException(args.Result as Exception);
                    return;
                }
                bool b = (args.Result as bool?) ?? false;
                if (b)
                {
                    Utils.showInformation(Utils.Messages.ORDERED_SUCCESSFULLY);
                    OrderedPizzasCollection.Clear();
                }
                else
                    Utils.showExclamation(Utils.Messages.ORDERING_ERROR);
            }, details));
        }
Beispiel #13
0
        public void RefreshRecipes()
        {
            this.IngredientsCollection.Clear();
            this.RecipesCollection.Clear();
            this.OrderedPizzasCollection.Clear();
            this.Ingredients.Clear();

            Worker.EnqueueTask(new WorkerTask((args) =>
            {
                try
                {
                    using (var proxy = new WorkChannel())
                    {
                        return proxy.GetRecipeTabData(new PizzaNetCommon.Requests.EmptyRequest
                        {
                            Login = ClientConfig.CurrentUser.Email,
                            Password = ClientConfig.CurrentUser.Password
                        });
                    }
                    //using (var db = new PizzaUnitOfWork())
                    //{
                    //    return db.inTransaction(uof =>
                    //    {
                    //        Console.WriteLine("LoadDataStart");
                    //        var result = new Trio<IEnumerable<Recipe>, PizzaNetDataModel.Model.Size[], IEnumerable<Ingredient>>
                    //        {
                    //            First = uof.Db.Recipies.FindAllEagerly(),
                    //            Second = uof.Db.Sizes.FindAll().ToArray(),
                    //            Third = uof.Db.Ingredients.FindAll()
                    //        };

                    //        Console.WriteLine("after query");

                    //        Console.WriteLine("Result is null: {0}", result == null);

                    //        return result;
                    //    });
                    //}
                }
                catch (Exception exc)
                {
                    return exc;
                }
            }, (s, args) =>
            {
                if (args.Result is Exception)
                {
                    Utils.HandleException(args.Result as Exception);
                    return;
                }
                var result = args.Result as TrioResponse<List<RecipeDTO>, List<SizeDTO>, List<OrderIngredientDTO>>;
                if (result == null)
                {
                    Utils.showExclamation(Utils.Messages.RECIPES_REFRESH_FAILED);
                    return;
                }
                if (result.Second.Count != 3) throw new Exception(INVALID_SIZES_COUNT);
                foreach (var item in result.First)
                {
                    var rc = new RecipeControl();
                    rc.Recipe = item;
                    rc.RecalculatePrices(result.Second.ToArray());
                    RecipesCollection.Add(rc);
                    Console.WriteLine(item.Name);
                }
                foreach (var item in result.Third)
                {
                    var row = new IngredientsRow(item, 0, result.Second[0]);
                    row.PropertyChanged += row_PropertyChanged;
                    IngredientsCollection.Add(row);
                    Ingredients.Add(item);
                }
                // MODIFIED Tag uses now dependency property
                SmallSize = result.Second[0];
                MedSize = result.Second[1];
                GreatSize = result.Second[2];
                CurrentSizeValue = result.Second[0];
            }));
        }
Beispiel #14
0
        internal void SaveChanges()
        {
            Worker.EnqueueTask(new WorkerTask(args =>
                {
                    try
                    {
                        using (var proxy = new WorkChannel())
                        {
                            List<RecipeDTO> toUpdate = new List<RecipeDTO>();
                            foreach (var recControl in RecipesCollection)
                            {
                                toUpdate.Add(recControl.Recipe);
                            }
                            return proxy.UpdateOrRemoveRecipe(new UpdateOrRemoveRequest<List<RecipeDTO>>
                            {
                                Data = toUpdate,
                                DataToRemove = RemovedRecipes,
                                Login = ClientConfig.CurrentUser.Email,
                                Password = ClientConfig.CurrentUser.Password
                            });
                        }
                    }
                    catch (Exception exc)
                    {
                        Console.WriteLine(exc.Message);
                        Console.WriteLine("Failed");
                        return exc;
                    }
                }, (s, e) =>
                    {
                        if (e.Result is Exception)
                        {
                            Utils.HandleException(e.Result as Exception);
                            return;
                        }
                        var result = e.Result as TrioResponse<List<RecipeDTO>, List<OrderIngredientDTO>, int>;
                        if (result == null)
                        {
                            Utils.showError(Utils.Messages.UNKNOWN_ERROR_FORMAT);
                            return;
                        }

                        RecipesCollection.Clear();
                        IngredientsRowsCollection.Clear();
                        RemovedRecipes.Clear();
                        foreach (var item in result.First)
                        {
                            var rc = new RecipeControl();
                            rc.Recipe = item;
                            //rc.RecalculatePrices(result.Second.ToArray());
                            rc.Update(Sizes);
                            RecipesCollection.Add(rc);
                        }
                        foreach (var item in result.Second)
                        {
                            var row = new IngredientsRowWork(item, false);
                            row.ButtonIncludeChanged += row_PropertyChanged;
                            IngredientsRowsCollection.Add(row);
                        }
                        Modified = false;
                    }, null));
        }
 internal void SaveUserInfo()
 {
     Worker.EnqueueTask(new WorkerTask(args =>
         {
             try
             {
                 using (var proxy = new WorkChannel())
                 {
                     var data = new UserDTO
                     {
                         UserID = User.UserID,
                         Address = User.Address,
                         Email = User.Email,
                         Name = User.Name,
                         Password = null,
                         Phone = User.Phone,
                         Rights = User.Rights
                     };
                     return proxy.UpdateUser(new UpdateRequest<UserDTO>()
                     {
                         Login = User.Email,
                         Password = User.Password,
                         Data = data
                     });
                 }
             }
             catch (Exception exc)
             {
                 return exc;
             }
         }, (s, e) =>
         {
             if (e.Result is Exception)
             {
                 Utils.HandleException(e.Result as Exception);
                 return;
             }
             var userRes = e.Result as SingleItemResponse<UserDTO>;
             if (userRes == null)
             {
                 Utils.showError(Utils.Messages.UNKNOWN_ERROR_FORMAT);
                 return;
             }
             ClientConfig.CurrentUser.UpdateWithUserDTO(userRes.Data);
             ClientConfig.CurrentUser.RefreshRate = this.User.RefreshRate;
             this.User = ClientConfig.CurrentUser;
             ModifiedUserData = false;
             Utils.showInformation(Utils.Messages.SAVED_SUCCESSFULLY);
         }, null));
 }
Beispiel #16
0
        public void RefreshRecipies()
        {
            Modified = false;
            RecipesCollection.Clear();
            IngredientsRowsCollection.Clear();
            Worker.EnqueueTask(new WorkerTask((args) =>
            {
                try
                {
                    using (var proxy = new WorkChannel())
                    {
                        return proxy.GetRecipeTabData(new EmptyRequest
                        {
                            Login = ClientConfig.CurrentUser.Email,
                            Password = ClientConfig.CurrentUser.Password
                        });
                    }
                    //        using (var db = new PizzaUnitOfWork())
                    //        {
                    //            return db.inTransaction(uof =>
                    //            {
                    //                Console.WriteLine("LoadDataStart");
                    //                var result = new Trio<IEnumerable<Recipe>, PizzaNetDataModel.Model.Size[], IEnumerable<Ingredient>>
                    //                {
                    //                    First = db.Recipies.FindAllEagerly(),
                    //                    Second = db.Sizes.FindAll().ToArray(),
                    //                    Third = db.Ingredients.FindAll()
                    //                };

                    //                Console.WriteLine("after query");

                    //                Console.WriteLine("Result is null: {0}", result == null);

                    //                return result;
                    //            });
                    //        }
                }
                catch (Exception exc)
                {
                    Console.WriteLine(exc.Message);
                    return exc;
                }
            }, (s, args) =>
            {
                if (args.Result is Exception)
                {
                    Utils.HandleException(args.Result as Exception);
                    return;
                }
                var result = args.Result as TrioResponse<List<RecipeDTO>, List<SizeDTO>, List<OrderIngredientDTO>>;
                //    var result = args.Result as Trio<IEnumerable<Recipe>, PizzaNetDataModel.Size[], IEnumerable<Ingredient>>;
                if (result == null)
                {
                    Console.WriteLine("Result is null");
                    Utils.showError(Utils.Messages.UNKNOWN_ERROR_FORMAT);
                    return;
                }
                foreach (var item in result.First)
                {
                    var rc = new RecipeControl();
                    rc.Recipe = item;
                    rc.Update(result.Second.ToArray());
                    RecipesCollection.Add(rc);
                }
                foreach (var item in result.Third)
                {
                    var row = new IngredientsRowWork(item, false);
                    row.ButtonIncludeChanged += row_PropertyChanged;
                    IngredientsRowsCollection.Add(row);
                }

                Sizes = result.Second.ToArray();
                //    foreach (var item in result.First)
                //    {
                //        var rc = new RecipeControl();
                //        rc.Recipe = item;
                //        rc.RecalculatePrices(result.Second.ToArray());
                //        RecipesCollection.Add(rc);
                //        Console.WriteLine(item.Name);
                //    }
                //    foreach (var item in result.Third)
                //    {
                //        var row = new IngredientsRowWork(item, false);
                //        row.ButtonIncludeChanged += row_PropertyChanged;
                //        IngredientsRowsCollection.Add(row);
                //    }
            }));
        }
 private void ButtonSignUp_Click(object sender, RoutedEventArgs e)
 {
     if (Password.Length == 0 || !RepeatedPassword.Equals(Password))
     {
         Utils.showExclamation(INVALID_PASSWORD);
         return;
     }
     if (!Utils.IsEmailValid(emailInput.Text))
     {
         Utils.showExclamation(INVALID_EMAIL);
         return;
     }
     if (addressInput.Text.Length == 0)
     {
         Utils.showExclamation(INVALID_ADDRESS);
         return;
     }
     int phone = 0;
     int.TryParse(phoneInput.Text, out phone);
     UserDTO user = new UserDTO()
     {
         Address = addressInput.Text,
         Email = emailInput.Text,
         Password = Password,
         Name = nameInput.Text,
         Phone = phone
     };
     worker.EnqueueTask(new WorkerTask((args) =>
         {
             var us = args[0] as UserDTO;
             if (us == null)
                 return null;
             try
             {
                 using (var proxy = new WorkChannel())
                 {
                     return proxy.RegisterUser(new UpdateRequest<UserDTO>()
                     {
                         Data = user
                     });
                 }
             }
             catch (Exception exc)
             {
                 return exc;
             }
         },
         (s, x) =>
         {
             var exc = x.Result as Exception;
             if (exc != null)
             {
                 Utils.HandleException(exc);
                 return;
             }
             var res = x.Result as SingleItemResponse<UserDTO>;
             if (res == null)
             {
                 Utils.showExclamation(Utils.Messages.REGISTRATION_FAILED);
                 return;
             }
             else
             {
                 Utils.showInformation(Utils.Messages.REGISTRATION_COMPLETED);
                 this.Close();
                 return;
             }
         }, user));
 }
 private void ValidateLogin(WorkerTask.WorkFinishedHandler handler, string login, string password)
 {
     worker.EnqueueTask(new WorkerTask(
         (args) =>
         {
             var log = args[0] as string;
             var pass = args[1] as string;
             try
             {
                 using (var proxy = new WorkChannel())
                 {
                     var result = proxy.GetUser(new EmptyRequest() { Login = log, Password = pass });
                     if (result == null) return null;
                     return result.Data;
                 }
             }
             catch(Exception exc)
             {
                 Console.WriteLine(exc.Message);
                 return exc;
             }
         },handler, login, password));
 }
 //
 // GET: /Index/
 public ActionResult Index()
 {
     List<OrderDTO> orders = new List<OrderDTO>();
     using (var proxy = new WorkChannel())
     {
         var result = proxy.GetOrders(new PizzaNetCommon.Requests.EmptyRequest { Login = "******", Password = "******" });
         orders = result.Data;
     }
     return View(orders);
 }