Example #1
0
        public ActionResult Update(Person person)
        {
            PersonDb db = new PersonDb(_connectionString);

            db.Update(person);
            return(Json(person));
        }
Example #2
0
        internal override CCR Execute(List <string> args, PersonDb db)
        {
            if (args.Count < 2)
            {
                return(CCR.INVALIDPARAM);
            }

            Error result = DbInterface.ChangePlayer(args[0], db, args[1], args.Count > 2 ? args[2] : "");

            StringBuilder outMessage = new StringBuilder();

            switch (result)
            {
            case Error.OK:
                outMessage.Append("Player changed successfully!");
                break;

            case Error.SAVEERROR:
                outMessage.Append("Player could not be saved to the Database!");
                break;

            case Error.NOTFOUND:
                outMessage.Append("Could not find a player with the given UID!");
                break;

            case Error.UNKNOWN:
            default:
                outMessage.Append("An Unknown Error Occured!");
                break;
            }
            Console.WriteLine(outMessage.ToString());

            return(CCR.OK);
        }
        public void DeletePersonCommand(object parameter)
        {
            if (parameter is DataGrid)
            {
                List <int> ids          = new List <int>();
                DataGrid   dtGridPerson = (DataGrid)parameter;
                if (dtGridPerson.SelectedItem == null)
                {
                    MessageBox.Show("Please select a record to be deleted from the datagrid ");
                    return;
                }

                DataTable table = new DataTable();
                table.Columns.Add("id", typeof(int));
                foreach (var person in dtGridPerson.SelectedItems)
                {
                    int id = ((BasePerson)person).Id;
                    table.Rows.Add(id);
                }
                PeopleCollection = PersonDb.DeletePersons(table);
            }
            else
            {
                MessageBox.Show("Please select a record to be deleted from the datagrid ");
            }
        }
Example #4
0
        public ActionResult GetPeople()
        {
            Thread.Sleep(3000);
            PersonDb db = new PersonDb(Properties.Settings.Default.ConStr);

            return(Json(db.GetPeople(), JsonRequestBehavior.AllowGet));
        }
Example #5
0
        public IActionResult Add(Person person)
        {
            var db = new PersonDb(@"Data Source=.\sqlexpress;Initial Catalog=OneToManyDemo;Integrated Security=true;");

            db.Add(person);
            return(Json(person));
        }
Example #6
0
        public IActionResult EditPerson(Person person)
        {
            PersonDb personDB = new PersonDb(_connectionString);

            personDB.EditPerson(person);
            return(Json(person));
        }
Example #7
0
        internal override bool Execute(List <string> args, TextMessage message, PersonDb db)
        {
            StringBuilder outMessage = new StringBuilder();
            CasinoPlayer  invoker    = DbInterface.GetPlayer(message.InvokerUid, db);

            outMessage.Append("\n");
            if (invoker.Inventory != null || invoker.Inventory.Length > 0)             //Don't have any items? frick off
            {
                String[] inventory = invoker.Inventory.Split(";");

                foreach (string itemID in inventory)
                {
                    Item item = store.GetItemFromID(itemID);
                    if (item != null)
                    {
                        outMessage.Append($"{item.Name} | {item.Description}\n");
                    }
                }
            }
            else
            {
                outMessage.Append($"You don't have any Items!\nYou can buy some with {CommandManager.CmdIndicator}{store.Label}");
            }

            CommandManager.AnswerCall(message, outMessage.ToString());

            return(false);
        }
Example #8
0
        public IActionResult GetAll()
        {
            var           db  = new PersonDb(@"Data Source=.\sqlexpress;Initial Catalog=OneToManyDemo;Integrated Security=true;");
            List <Person> ppl = db.GetAll();

            return(Json(ppl));
        }
Example #9
0
        public IActionResult DeletePerson(int id)
        {
            PersonDb db = new PersonDb(_conn);

            db.DeletePerson(id);
            return(Json(id));
        }
Example #10
0
        public ActionResult Add(Person person)
        {
            PersonDb db = new PersonDb(_connectionString);

            db.AddPerson(person);
            return(Json(person));
        }
Example #11
0
 internal static CCR ExecuteCommand(ConsoleCommandBase cmd, List <String> args)
 {
     using (PersonDb db = new PersonDb())
     {
         return(cmd.Execute(args, db));
     }
 }
Example #12
0
        public IActionResult EditPerson(Person person)
        {
            PersonDb db = new PersonDb(_conn);

            db.EditPerson(person);
            return(Json(person));
        }
Example #13
0
        public ListOfPersons GetListOfPersonWithDescription(ISqlFactory iSqlFactory)
        {
            ListOfPersons lPerson = new ListOfPersons();

            try
            {
                IPersonDB person   = new PersonDb();
                var       ageGroup = GetListOfAgeGroup(iSqlFactory);

                lPerson = person.GetDataFromPersonTable(iSqlFactory);

                foreach (var item in lPerson.lPersonModel)
                {
                    item.Description = ageGroup.ListOfAgeGroup.Where(x => x.MinAge <= item.Age && x.MaxAge > item.Age).Select(z => z.Description).SingleOrDefault();
                }
            }
            catch (DbException ex)
            {
                lPerson.Message.Add(new Response
                {
                    MessageCode    = "Error",
                    MessageDetails = ex.Message
                });
            }

            return(lPerson);
        }
Example #14
0
        public UserDTO mappingUserObject(UserDb user, PersonDb person, WorkshopDb workshop)
        {
            UserDTO userData = new UserDTO();

            userData.user_id     = user.userId;
            userData.accessToken = user.accessToken;
            userData.countryCode = Convert.ToInt32(user.countryCode);
            userData.phoneNumber = user.phoneNumber;
            userData.userType    = user.userType;
            userData.userImage   = user.userImage;


            userData.firstName = person.firstName;
            userData.lastName  = person.lastName;


            userData.shopNumber = Convert.ToInt32(workshop.shopNumber);
            userData.shopName   = workshop.shopName;
            userData.cityId     = workshop.cityId;
            userData.cityName   = workshop.cityName;
            userData.address    = workshop.address;
            userData.Lat        = workshop.lat;
            userData.Lng        = workshop.lng;



            return(userData);
        }
Example #15
0
        public ListOfPersons SearchForPerson(PersonModel personModel, ISqlFactory iSqlFactory)
        {
            ListOfPersons lSearchPerson = new ListOfPersons();

            try
            {
                IPersonDB person  = new PersonDb();
                var       lPerson = GetListOfPersonWithDescription(iSqlFactory);
                lSearchPerson.lPersonModel = lPerson.lPersonModel.Where(x => x.FirstName == personModel.FirstName || x.LastName == personModel.LastName)
                                             .Select(z => new PersonModel {
                    Id          = z.Id,
                    FirstName   = z.FirstName,
                    LastName    = z.LastName,
                    Age         = z.Age,
                    Description = z.Description
                }).ToList();
            }
            catch (DbException ex)
            {
                lSearchPerson.Message.Add(new Response
                {
                    MessageCode    = "Error",
                    MessageDetails = ex.Message
                });
            }

            return(lSearchPerson);
        }
Example #16
0
        internal override bool Execute(List <string> args, TextMessage message, PersonDb db)
        {
            StringBuilder outMessage = new StringBuilder();
            Error         result     = DbInterface.AddPlayer(message.InvokerUid, message.InvokerName, db, args.Count > 0 ? args[0] : "");

            outMessage.Append("\n");

            switch (result)
            {
            case Error.OK:
                outMessage.Append("Player added successfully!");
                break;

            case Error.DUPLICATE:
                outMessage.Append("Player already exists in the Database");
                break;

            case Error.INVALIDNAME:
                outMessage.Append("Name already exists within the Database");
                break;

            case Error.SAVEERROR:
                outMessage.Append("Player could not be saved to the Database!");
                break;

            case Error.UNKNOWN:
            default:
                outMessage.Append("An Unknown Error Occured");
                break;
            }
            CommandManager.AnswerCall(message, outMessage.ToString());

            return(false);
        }
Example #17
0
        public ActionResult ViewAll()
        {
            ViewAllViewModel vm = new  ViewAllViewModel();

            vm.People = PersonDb.GetAll();
            return(View(vm));
        }
Example #18
0
        public IActionResult DeletePerson(int id)
        {
            PersonDb personDB = new PersonDb(_connectionString);

            personDB.DeletePerson(id);
            return(Json(id));
        }
Example #19
0
        public ActionResult Update(Person person)
        {
            PersonDb db = new PersonDb(Properties.Settings.Default.ConStr);

            db.Update(person);
            return(Json(person));
        }
Example #20
0
        internal override CCR Execute(List <string> args, PersonDb db)
        {
            if (args.Count > 1)
            {
                return(CCR.WRONGPARAM);
            }

            StringBuilder outputMessage = new StringBuilder();

            if (args.Count != 0)
            {
                foreach (KeyValuePair <String, ConsoleCommandBase> cmd in ConsoleCommandManager.Commands)
                {
                    if (args[0] == cmd.Key)
                    {
                        outputMessage.Append(cmd.Value.GetUsage() + "\n");
                        Console.Write(outputMessage.ToString());
                        return(CCR.OK);
                    }
                }
                return(CCR.INVALIDPARAM);
            }
            else
            {
                foreach (KeyValuePair <String, ConsoleCommandBase> cmd in ConsoleCommandManager.Commands)
                {
                    outputMessage.
                    Append(cmd.Key + "").
                    Append(": ").
                    Append(cmd.Value.Description + "\n");
                }
                Console.WriteLine(outputMessage.ToString());
                return(CCR.OK);
            }
        }
Example #21
0
        public IActionResult GetPeople()
        {
            Thread.Sleep(2000);
            PersonDb db = new PersonDb(_connectionString);

            return(Json(db.GetPeople()));
        }
Example #22
0
        public int AddMoneyToCard(int id, double value)
        {
            Person person = GetPersonById(id);

            person.Balance += value;
            return(PersonDb.UpdatePersonBalance(person));
        }
Example #23
0
        public IActionResult People()
        {
            PersonDb      personDB = new PersonDb(_connectionString);
            List <Person> people   = personDB.GetPeople();

            return(Json(people));
        }
Example #24
0
        async void Save_Clicked(object sender, System.EventArgs e)
        {
            var      personItem = (Person)BindingContext;
            PersonDb person     = new PersonDb();

            person.SavePerson(personItem);
            await Navigation.PopAsync();
        }
 public static ListPerson CreateListPerson(PersonDb personDb)
 {
     return(new ListPerson
     {
         Id = personDb.Id,
         Label = personDb.PreferredName + " " + FindDates(personDb)
     });
 }
Example #26
0
        public Object GetPerson(int id)
        {
            Person p = new Person();

            p.Id = id;
            PersonDb logDb = new PersonDb();

            return(logDb.GetPerson(p));
        }
Example #27
0
        public ActionResult AddPeople(IEnumerable <Person> people)
        {
            foreach (Person person in people)
            {
                PersonDb.Add(person);
            }

            return(Redirect("/home/viewall"));
        }
Example #28
0
        public Person Login(string UserName, string Password)
        {
            Person p = new Person();

            p.UserName = UserName;
            p.Password = Password;
            PersonDb logDb = new PersonDb();

            return(logDb.Login(p));
        }
        public IActionResult Index()
        {
            PersonDb        db = new PersonDb(_connectionString);
            PeopleViewModel vm = new PeopleViewModel
            {
                People = db.GetPeople()
            };

            return(View(vm));
        }
        public IActionResult AddPeople(List <Person> ppl)
        {
            PersonDb db = new PersonDb(_connectionString);

            foreach (Person person in ppl)
            {
                db.AddPerson(person);
            }
            return(Redirect("/"));
        }