Ejemplo n.º 1
0
        public ActionResult Delete(string userId, string listId)
        {
            ShoppingClient sc = new ShoppingClient();
            bool           value;

            value = sc.DeleteList(Guid.Parse(listId), Guid.Parse(userId));
            return(RedirectToAction("List", "Home"));
        }
Ejemplo n.º 2
0
 public ActionResult Register(Register user)
 {
     if (ModelState.IsValid)
     {
         ShoppingClient sc = new ShoppingClient();
         bool           value;
         value = sc.Register(user.login, user.email, user.password);
         return(RedirectToAction("LogIn"));
     }
     else
     {
         return(View());
     }
 }
Ejemplo n.º 3
0
        public ActionResult LogIn(User loginData)
        {
            ShoppingClient sc = new ShoppingClient();

            Session["userId"] = sc.Login(loginData.Login, loginData.Password).ToString();
            if (Session["userId"].ToString() != "00000000-0000-0000-0000-000000000000")
            {
                return(RedirectToAction("List", new { userId = (Guid.Parse(Session["userId"].ToString())) }));
            }
            else
            {
                return(View());
            }
        }
Ejemplo n.º 4
0
        public ActionResult ListDetail(string id)
        {
            List <ListProduct> l = new List <ListProduct>();

            ShoppingClient sc = new ShoppingClient();

            l = sc.GetProductsFromList((Guid.Parse(id))).ToList();
            Mapper.CreateMap <ListProduct, Product>();
            List <Product> list = Mapper.Map <List <ListProduct>, List <Product> >(l);
            ProductModel   p    = new ProductModel();

            p.Product      = list;
            ViewBag.ListId = id;
            return(View(p));
        }
Ejemplo n.º 5
0
        public ActionResult List(Guid?userId)
        {
            if (userId == null)
            {
                userId = Guid.Parse(Session["userId"].ToString());
            }
            ShoppingClient  sc   = new ShoppingClient();
            List <ListUser> list = new List <ListUser>();

            list = sc.GetUserList((Guid)userId);



            return(View(list));
        }
Ejemplo n.º 6
0
        public ActionResult Add(ListProduct l, string id)
        {
            ShoppingClient sc = new ShoppingClient();
            bool           value;

            value = sc.AddProductToList(l.ProductName, Guid.Parse(id));
            if (value)
            {
                return(RedirectToAction("ListDetail", "Home", new { id = (Guid.Parse(id)) }));
            }
            else
            {
                return(View());
            }
        }
Ejemplo n.º 7
0
        public ActionResult Create(List l)
        {
            ShoppingClient sc = new ShoppingClient();
            bool           value;

            value = sc.CreateNewList(l.ListName, (Guid.Parse(Session["userId"].ToString())));
            if (value)
            {
                return(RedirectToAction("List", "Home", new { userId = (Guid.Parse(Session["userId"].ToString())) }));
            }
            else
            {
                return(View());
            }
        }
Ejemplo n.º 8
0
        public ActionResult Sync(ProductModel products)
        {
            Dictionary <Guid, bool> p = new Dictionary <Guid, bool>();

            foreach (var item in products.Product)
            {
                p.Add(item.ProductId, item.IsBought);
            }
            ShoppingClient sc = new ShoppingClient();
            Guid           id = new Guid();

            id = products.Product[1].ListId;
            bool value = false;

            value = sc.Sync(p, id);

            return(View());
        }
        public void Init()
        {
            //Clients
            IClient client1 = new Organization(111, "FTN", "Adress1", "111-111", "*****@*****.**");

            client1.Id = new Guid("00000000-0000-0000-0000-400000000001");
            IClient client2 = new Organization(111, "Bambi", "Adress2", "222-222", "*****@*****.**");

            client2.Id = new Guid("00000000-0000-0000-0000-400000000002");
            IClient client3 = new User("user1", "suruser1", "*****@*****.**", "333-333", "Adress1");
            IClient client4 = new User("user2", "suruser2", "*****@*****.**", "444-444", "Adress2");

            List <IClient> list = new List <IClient>()
            {
                client1, client2, client3, client4
            };

            clientList = new ShoppingClient(list);
        }
Ejemplo n.º 10
0
 public FinanceManager(ShoppingClient clientList, BankList bankList)
 {
     this.ClientList = clientList;
     this.BankList   = bankList;
 }
Ejemplo n.º 11
0
        public void Init()
        {
            //Clients
            IClient client1 = new Organization(111, "FTN", "Adress1", "111-111", "*****@*****.**");

            client1.Id = new Guid("00000000-0000-0000-0000-400000000001");
            IClient client2 = new Organization(111, "Bambi", "Adress2", "222-222", "*****@*****.**");

            client2.Id = new Guid("00000000-0000-0000-0000-400000000002");
            IClient client3 = new User("user1", "suruser1", "*****@*****.**", "333-333", "Adress1");

            client3.Id = new Guid("00000000-0000-0000-0000-400000000003");
            IClient client4 = new User("user2", "suruser2", "*****@*****.**", "444-444", "Adress2");

            List <IClient> list = new List <IClient>()
            {
                client1, client2, client3, client4
            };
            ShoppingClient clientList = new ShoppingClient(list);

            //Credits
            ICredit credit1 = new Credit(400, 500, 1.5, 2, 6, true);

            credit1.Id        = new Guid("00000000-0000-0000-0000-500000000001");
            credit1.Available = false;
            ICredit credit2 = new Credit(300, 500, 2.8, 1, 2, false);

            credit2.Id = new Guid("00000000-0000-0000-0000-500000000002");
            ICredit credit3 = new Credit(200, 600, 1.6, 1, 3, true);

            credit3.Id = new Guid("00000000-0000-0000-0000-500000000003");
            ICredit credit4 = new Credit(100, 600, 1.7, 5, 6, true);

            credit4.Id = new Guid("00000000-0000-0000-0000-500000000004");

            //Banks
            IBank bank1 = new Bank("bank1", "addr1", "*****@*****.**", "555-555");

            bank1.CreditOffer = new List <ICredit>()
            {
                credit1, credit2
            };
            IBank bank2 = new Bank("bank2", "addr2", "*****@*****.**", "666-666");

            bank2.CreditOffer = new List <ICredit>()
            {
                credit3
            };
            IBank bank3 = new Bank("bank3", "addr3", "*****@*****.**", "777-777");

            bank3.CreditOffer = new List <ICredit>()
            {
                credit4
            };

            List <IBank> banks = new List <IBank>()
            {
                bank1, bank2, bank3
            };
            BankList bankList = new BankList(banks);

            var financeManager = new FinanceManager(clientList, bankList);

            userManager = new ClientManager(clientList, financeManager);
        }
Ejemplo n.º 12
0
        public JsonResult IsEmailAlredyExist(string email)
        {
            ShoppingClient sc = new ShoppingClient();

            return(Json(!sc.CheckEmailIsExist(email), JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 13
0
        public JsonResult IsLoginAlredyExist(string login)
        {
            ShoppingClient sc = new ShoppingClient();

            return(Json(!sc.CheckLoginIsExist(login), JsonRequestBehavior.AllowGet));
        }