Esempio n. 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            var user = AspNetSecurityHelper.currentAppUser;

            if (user != null)
            {
                CityManager _CityManager = new CityManager();
                SSAManager  _SSAManager  = new SSAManager();

                DAL.Entity.City obj = _CityManager.GetCity(queryStringId);
                if (obj == null)
                {
                    obj = new DAL.Entity.City();
                }

                obj.Name = txtCity.Text;

                int s = 0;
                if (int.TryParse(ddlState.SelectedValue, out s))
                {
                    obj.StateId = s;
                }

                int i = 0;
                if (obj.Id == 0)
                {
                    obj.CreatedBy   = user.UserName;
                    obj.CreatedDate = DateTime.Now;
                    obj.DeletedFlag = false;
                    i               = _CityManager.AddCity(obj);
                    Operation       = (String)GetGlobalResourceObject("HCMResource", "Add");
                    btnSave.Visible = false;
                }
                else
                {
                    obj.LastUpdatedBy   = user.UserName;
                    obj.LastUpdatedDate = DateTime.Now;
                    i         = _CityManager.UpdateCity(obj);
                    Operation = (String)GetGlobalResourceObject("HCMResource", "Update");
                }
                if (i != 0)
                {
                    ucAlertMessage.AlertMessage(String.Format((String)GetGlobalResourceObject("HCMResource", "OperationSuccess"), Operation), "", Common.msgType.alertMessageSuccess);
                    FillData();
                }
                else
                {
                    ucAlertMessage.AlertMessage(String.Format((String)GetGlobalResourceObject("HCMResource", "OperationError"), Operation), "", Common.msgType.alertMessageDanger);
                }
            }
            else
            {
                Response.Redirect("/");
            }
        }
 // Dodaje novi grad u državu
 //[Authorize(Roles = "Administrator")]
 public ActionResult AddCity(CityVM c)
 {
     if (!User.IsInRole("Administrator"))
     {
         return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
     }
     else if (ModelState.IsValid)
     {
         CityManager.AddCity(c);
         return(new HttpStatusCodeResult(HttpStatusCode.OK));
     }
     return(new HttpStatusCodeResult(HttpStatusCode.NotModified));
 }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string CityName = txtCrCity.Text;

            State _state = new State();

            if (dpStateCity.SelectedItem.Value != "None" && dpStateCity.SelectedItem.Value != "none")
            {
                _state.StateId = long.Parse(dpStateCity.SelectedItem.Value);
            }

            City _city = new City();

            _city.Name      = CityName;
            _city.StateInfo = _state;

            CityManager _cityManger = new CityManager();

            try
            {
                if (_cityManger.AddCity(_city))
                {
                    lblError.Text = "City Added Successfully";
                }
                else
                {
                    lblError.Text = "City already exists";
                }
            }
            catch (CityManagerException ex)
            {
                lblError.Text = ex.Message;
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
            }
        }
Esempio n. 4
0
 public void AddCity(HexCoordinates hexCoordinates)
 {
     cityManager.AddCity(hexCoordinates);
 }
        static void Main(string[] args)
        {
            var customerDbManager    = new CustomerManager(Configuration);
            var deliverymanDbManager = new DeliverymanManager(Configuration);
            var deliveryDbManager    = new DeliveryManager(Configuration);
            var orderDbManager       = new OrderManager(Configuration);
            var cityDbManager        = new CityManager(Configuration);

            Console.WriteLine("Customer [C], Deliveryman [D]");
            string customerDeliverymanChoice = Console.ReadLine();


            if (customerDeliverymanChoice == "C")
            {
                Console.WriteLine("Already registered [1], New registration [2]");
                string registrationChoice = Console.ReadLine();
                if (registrationChoice == "1")
                {
                    Console.WriteLine("Username");
                    string usernameC = Console.ReadLine();


                    Console.WriteLine("Password");
                    string passwordC = Console.ReadLine();

                    int idCustomerTryingToConnect = customerDbManager.GetIdCustomer(usernameC);

                    //En fonction de l'id du customer
                    while (passwordC != customerDbManager.GetPassword(idCustomerTryingToConnect, usernameC))
                    {
                        Console.WriteLine(passwordC);
                        Console.WriteLine("Connection denied. Try again");

                        Console.WriteLine("Username");
                        usernameC = Console.ReadLine();

                        Console.WriteLine("Password");
                        passwordC = Console.ReadLine();

                        idCustomerTryingToConnect = customerDbManager.GetIdCustomer(usernameC);
                    }

                    Console.WriteLine("Connection successful");

                    Program.Suite(idCustomerTryingToConnect);
                }
                else
                {
                    Console.WriteLine("New registration !");

                    Console.WriteLine("Name : ");
                    string nameNewCustomer = Console.ReadLine();
                    Console.WriteLine("Lastname : ");
                    string lastNameNewCustomer = Console.ReadLine();
                    Console.WriteLine("City : ");
                    string cityNewCustomer = Console.ReadLine();
                    Console.WriteLine("ZIP : ");
                    string zipNewCustomer = Console.ReadLine();
                    int    idCity         = cityDbManager.GetIdCity(cityNewCustomer.ToLower(), zipNewCustomer);
                    if (idCity == 0)
                    {
                        cityDbManager.AddCity(new City {
                            Name = cityNewCustomer, Zip_code = int.Parse(zipNewCustomer)
                        });
                        idCity = cityDbManager.GetIdCity(cityNewCustomer.ToLower(), zipNewCustomer);
                    }
                    Console.WriteLine("Address : ");
                    string addressNewCustomer = Console.ReadLine();
                    Console.WriteLine("Login : "******"Password : "******"Congratulations, your account has been created ! You can now start ordering food !");

                    int idNewCustomer = customerDbManager.GetIdCustomer(LoginNewCustomer);
                    Program.Suite(idNewCustomer);
                }
            }
            else
            {
                Console.WriteLine("Welcome to the delivery management");

                Console.WriteLine("Username");
                string usernameDM = Console.ReadLine();

                Console.WriteLine("Password");
                string passwordDM = Console.ReadLine();

                int idDeliverymanTryingToConnect = deliverymanDbManager.GetIdDeliveryman(usernameDM);

                //En fonction de l'id du customer
                while (passwordDM != deliverymanDbManager.GetPassword(idDeliverymanTryingToConnect, usernameDM))
                {
                    Console.WriteLine("Connection denied. Try again");

                    Console.WriteLine("Username");
                    usernameDM = Console.ReadLine();

                    Console.WriteLine("Password");
                    passwordDM = Console.ReadLine();
                }

                Console.WriteLine("Connection successful");

                Console.WriteLine("Which delivery have you done ? Insert the ID");

                var deliverys = deliveryDbManager.GetAllDelivery(idDeliverymanTryingToConnect); //En fonction de l'id du deliveryman
                foreach (var delivery in deliverys)
                {
                    Console.WriteLine(delivery.ToString());
                }

                string deliveryDone = Console.ReadLine();
                Console.WriteLine("Thank you ! The delivery " + deliveryDbManager.GetDelivery(int.Parse(deliveryDone)) + " has been successfully executed");
                //deliveryDbManager.changeStatusDeliveryToDone(idDelivery);
            }
        }