Ejemplo n.º 1
0
        public ShipperDTO GetShipperByLogin(string ShipperLogin)
        {
            using (SqlConnection conn = new SqlConnection(this.connectionString))
                using (SqlCommand comm = conn.CreateCommand())
                {
                    conn.Open();
                    ShipperDTO shipper = new ShipperDTO();

                    comm.CommandText = $"select * from Shipper where Login=@Login";
                    comm.Parameters.AddWithValue("@Login", ShipperLogin);
                    SqlDataReader reader = comm.ExecuteReader();

                    while (reader.Read())
                    {
                        shipper = new ShipperDTO
                        {
                            ShipperID   = Convert.ToInt32(reader["ShipperID"]),
                            Login       = reader["Login"].ToString(),
                            Password    = (byte[])(reader["Password"]),
                            EMail       = reader["EMail"].ToString(),
                            Addres      = reader["Adress"].ToString(),
                            Phone       = reader["Phone"].ToString(),
                            Description = reader["Description"].ToString(),
                        };
                    }

                    return(shipper);
                }
        }
Ejemplo n.º 2
0
        public int Login()
        {
            Console.WriteLine("Login to continue:\n");
            Console.WriteLine("Login: "******"Password: "******"select * from Shipper where Login= '******'";


                    PasswordActions decrypt = new PasswordActions();

                    SqlDataReader reader = comm.ExecuteReader();
                    while (reader.Read())
                    {
                        shipper.ShipperID = Convert.ToInt32(reader["ShipperID"]);
                        shipper.Login     = reader["Login"].ToString();
                        shipper.Password  = (byte[])reader["Password"];
                        if (shipper.Login != login || decrypt.PasswordDecryption(shipper.Password) != password)
                        {
                            throw new NotImplementedException("Incorrect Login or Password");
                        }
                    }
                    return(shipper.ShipperID);
                }
        }
Ejemplo n.º 3
0
        public void RemoveShipper(int ShipperID)
        {
            ShipperDTO shipper = new ShipperDTO();

            shipper.ShipperID = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine($"Deleting shipper ID: {shipper.ShipperID}");
            _shipperDAL.DeleteShipper(shipper.ShipperID);
        }
Ejemplo n.º 4
0
        public ShipperDTO GetShipperById(int id)
        {
            ShipperDTO list = db.Shippers.Where(s => s.ShipperID == id).Select(e => new ShipperDTO()
            {
                ShipperID   = e.ShipperID,
                CompanyName = e.CompanyName,
                Phone       = e.Phone
            }).FirstOrDefault();

            return(list);
        }
Ejemplo n.º 5
0
        public ShipperDTO ChangeShipper(ShipperDTO shipper)
        {
            Console.WriteLine("ShipperID, new EMail, Address, Phone, Description");
            shipper = new ShipperDTO
            {
                ShipperID   = Convert.ToInt32(Console.ReadLine()),
                EMail       = Console.ReadLine(),
                Addres      = Console.ReadLine(),
                Phone       = Console.ReadLine(),
                Description = Console.ReadLine()
            };


            return(_shipperDAL.UpdateShipper(shipper));
        }
Ejemplo n.º 6
0
        public IHttpActionResult PutShipper(ShipperDTO shipper)
        {
            Shipper shipperEdit = db.Shippers.FirstOrDefault(s => s.ShipperID == shipper.ShipperID);

            shipperEdit.CompanyName = shipper.CompanyName;
            shipperEdit.Phone       = shipper.Phone;

            if (db.SaveChanges() > 0)
            {
                return(Ok());
            }
            else
            {
                return(InternalServerError());
            }
        }
Ejemplo n.º 7
0
        public void UpdateShipperTest()
        {
            ShipperDAL dal     = new ShipperDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            var        shupper = dal.GetShipperById(13);
            ShipperDTO upd     = new ShipperDTO
            {
                ShipperID   = 13,
                EMail       = "Updated",
                Addres      = "Updated",
                Phone       = "Updated",
                Description = "Updated"
            };

            var result = dal.UpdateShipper(upd);

            Assert.IsTrue(result.EMail == "Updated", "Shipper was not updated");
        }
Ejemplo n.º 8
0
        public IHttpActionResult GetShipperById(int id)
        {
            ShipperDTO list = db.Shippers.Where(s => s.ShipperID == id).Select(e => new ShipperDTO()
            {
                CompanyName = e.CompanyName,
                Phone       = e.Phone
            }).FirstOrDefault();

            if (list != null)
            {
                return(Ok(list));
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 9
0
        public bool PutShipper(ShipperDTO shipper)
        {
            Shipper shipperInsert = db.Shippers.FirstOrDefault(s => s.ShipperID == shipper.ShipperID);

            shipperInsert.CompanyName = shipper.CompanyName;
            shipperInsert.Phone       = shipper.Phone;


            if (db.SaveChanges() > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 10
0
        public IHttpActionResult PostNewShipper(ShipperDTO shiper)
        {
            Shipper shipperInsert = new Shipper()
            {
                CompanyName = shiper.CompanyName,
                Phone       = shiper.Phone
            };

            db.Shippers.Add(shipperInsert);
            if (db.SaveChanges() > 0)
            {
                return(Ok());
            }
            else
            {
                return(InternalServerError());
            }
        }
Ejemplo n.º 11
0
        public ShipperDTO AddShipper(ShipperDTO shipper)
        {
            ConsoleProject.PasswordActions password = new ConsoleProject.PasswordActions();


            Console.WriteLine("Login, Password, Email, Address, Phone, Descrition: ");
            shipper = new ShipperDTO
            {
                Login       = Console.ReadLine(),
                Password    = password.PasswordEncryption(Console.ReadLine()),
                EMail       = Console.ReadLine(),
                Addres      = Console.ReadLine(),
                Phone       = Console.ReadLine(),
                Description = Console.ReadLine()
            };

            return(_shipperDAL.CreateShipper(shipper));
        }
Ejemplo n.º 12
0
        public ShipperDTO CreateShipper(ShipperDTO shipper)
        {
            using (SqlConnection conn = new SqlConnection(this.connectionString))
                using (SqlCommand comm = conn.CreateCommand())
                {
                    comm.CommandText = "insert into Shipper (Login, Password, EMail, Adress, Phone, Description) output INSERTED.ShipperID values (@Login, @Password, @EMail, @Adress, @Phone, @Description)";
                    comm.Parameters.Clear();
                    comm.Parameters.AddWithValue("@Login", shipper.Login);
                    comm.Parameters.AddWithValue("@Password", shipper.Password);
                    comm.Parameters.AddWithValue("@EMail", shipper.EMail);
                    comm.Parameters.AddWithValue("@Adress", shipper.Addres);
                    comm.Parameters.AddWithValue("@Phone", shipper.Phone);
                    comm.Parameters.AddWithValue("@Description", shipper.Description);
                    conn.Open();

                    shipper.ShipperID = Convert.ToInt32(comm.ExecuteScalar());
                    return(shipper);
                }
        }
Ejemplo n.º 13
0
        public bool PostNewShipper(ShipperDTO shipper)
        {
            Shipper shipperInsert = new Shipper()
            {
                ShipperID   = shipper.ShipperID,
                CompanyName = shipper.CompanyName,
                Phone       = shipper.Phone
            };

            db.Shippers.Add(shipperInsert);
            if (db.SaveChanges() > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 14
0
        public ShipperDTO UpdateShipper(ShipperDTO shipper)
        {
            using (SqlConnection conn = new SqlConnection(this.connectionString))
                using (SqlCommand comm = conn.CreateCommand())
                {
                    comm.CommandText = "update Shipper set EMail= @EMail, Adress=@Adress, Phone=@Phone, Description=@Description where ShipperID = @ShipperID";
                    comm.Parameters.Clear();
                    comm.Parameters.AddWithValue("@ShipperID", shipper.ShipperID);
                    comm.Parameters.AddWithValue("@EMail", shipper.EMail);
                    comm.Parameters.AddWithValue("@Adress", shipper.Addres);
                    comm.Parameters.AddWithValue("@Phone", shipper.Phone);
                    comm.Parameters.AddWithValue("@Description", shipper.Description);
                    conn.Open();

                    shipper.ShipperID = Convert.ToInt32(comm.ExecuteScalar());


                    return(shipper);
                }
        }
Ejemplo n.º 15
0
        public ActionResult Insert()
        {
            //HttpPostedFileBase file = Request.Files[0];
            ShipperDTO shipper = new ShipperDTO();

            //shipper.ShipperID = int.Parse(Request.Params["ShipperID"]);
            shipper.CompanyName = Request.Params["CompanyName"];
            shipper.Phone       = Request.Params["Phone"];

            bool check = new ShipperModels().PostNewShipper(shipper);

            if (check)
            {
                return(Json(new { Ok = true }));
            }
            else
            {
                return(Json(new { Ok = false }));
            }
        }
Ejemplo n.º 16
0
        public void CreateShipperTest()
        {
            ShipperDAL      dal      = new ShipperDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            PasswordActions password = new PasswordActions();



            var result = new ShipperDTO
            {
                Login       = "******",
                Password    = password.PasswordEncryption("1234"),
                EMail       = "Test",
                Addres      = "Test",
                Phone       = "Test",
                Description = "Test"
            };

            result = dal.CreateShipper(result);
            Assert.IsTrue(result.ShipperID >= 0, "returned ID should be more than zero");
        }
Ejemplo n.º 17
0
        public void AddShipperTest()
        {
            ItemDAL       itemDAL       = new ItemDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            ShipperDAL    shipperDAL    = new ShipperDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            CustomerDAL   customerDAL   = new CustomerDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            OrderDAL      orderDAL      = new OrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);;
            AddToOrderDAL addtoorderDAL = new AddToOrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString);
            User          result        = new User(shipperDAL, itemDAL, customerDAL, orderDAL, addtoorderDAL);

            var shipper = new ShipperDTO
            {
                Login       = "******",
                Password    = new ConsoleProject.PasswordActions().PasswordEncryption("1234"),
                EMail       = "Test2",
                Addres      = "Test2",
                Phone       = "Test2",
                Description = "Test2"
            };

            shipper = result.AddShipper(shipper);
            Assert.IsTrue(shipper.ShipperID >= 0, "returned ID should be more than zero");
        }
        private void shipperSignUpButtom_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Length == 0 || textBox2.Text.Length == 0 || textBox3.Text.Length == 0 || textBox4.Text.Length == 0 || textBox5.Text.Length == 0 || textBox6.Text.Length == 0)
            {
                MessageBox.Show("Invalid data");
            }
            else
            {
                ShipperDTO user = new ShipperDTO
                {
                    Login       = textBox1.Text,
                    Password    = new ConsoleProject.PasswordActions().PasswordEncryption(textBox2.Text),
                    EMail       = textBox3.Text,
                    Addres      = textBox4.Text,
                    Phone       = textBox5.Text,
                    Description = textBox6.Text
                };

                _shipper.AddShipper(user);
                var shipperMenu = new order_managerMenuForm(_shipper, user.ShipperID);
                shipperMenu.Show();
                this.Hide();
            }
        }
        public IActionResult InsertProducto([FromBody] ShipperDTO oShipper)
        {
            var a = oShipper;

            return(Ok(a));
        }
Ejemplo n.º 20
0
 public ShipperDTO AddShipper(ShipperDTO shipper)
 {
     return(_shipperDAL.CreateShipper(shipper));
 }
Ejemplo n.º 21
0
 public ShipperDTO ChangeShipper(ShipperDTO shipper)
 {
     return(_shipperDAL.UpdateShipper(shipper));
 }
Ejemplo n.º 22
0
 // DELETE api/<controller>
 public void Post([FromBody] ShipperDTO value)
 {
     Northwind.AddShipper(value.ToShipper());
 }
Ejemplo n.º 23
0
 // PUT api/<controller>/5
 public void Put(int id, [FromBody] ShipperDTO value)
 {
     value.ShipperID = id;
     Northwind.UpdateShipper(value.ToShipper());
 }