示例#1
0
        public static async Task <string[]> MainAsync()
        {
            RestClient.SetDomain("https://*****:*****@gmail.com",
                FName           = $"Name{random}",
                LName           = $"LName{random}",
                Password        = $"Password{random}",
                ConfirmPassword = $"Password{random}"
            });


            ThingDto dto = things.Get(1);

            dto.Household = households.Get(dto.HouseholdId);
            Console.WriteLine(JsonConvert.SerializeObject(dto));


            //      dto = complete thing, ready for use


            return("Oi");
        }
示例#2
0
        private void updateBtn_Click(object sender, RoutedEventArgs e)
        {
            if (nameTextBox.Text == "")
            {
                MessageBox.Show("Name is required.");
            }
            else
            {
                double defaultPrice = 0;

                if (defaultPriceTextBox.Text != "")
                {
                    try
                    {
                        defaultPrice = Double.Parse(defaultPriceTextBox.Text);
                    }
                    catch (FormatException a)
                    {
                        MessageBox.Show("Default Price must be a number.");
                    }
                }

                ThingDto thing = new ThingDto()
                {
                    Name         = nameTextBox.Text,
                    HouseholdId  = currentThing.HouseholdId,
                    Needed       = (bool)neededCheckBox.IsChecked,
                    DefaultPrice = defaultPrice,
                    Show         = true,
                };

                thingRest.Update(thing);
            }
        }
        public void Update()
        {
            //  Arrange
            var logic     = Mocks.GetMockedLogic();
            var testThing = Mocks.TestThing2;

            //  Act
            ThingDto dto = logic.Create(
                name: testThing.Name,
                householdId: testThing.HouseholdId,
                show: testThing.Show,
                needed: testThing.Needed,
                defaultPrice: testThing.DefaultPrice);

            //  Assert
            var updatedThing = logic.DatabaseContext.Things.Find(dto.ThingId);

            Assert.IsTrue(
                updatedThing.ThingId == 1 &&
                updatedThing.Show == testThing.Show &&
                updatedThing.Needed == testThing.Needed &&
                updatedThing.Name == testThing.Name &&
                updatedThing.HouseholdId == testThing.HouseholdId &&
                updatedThing.DefaultPrice == testThing.DefaultPrice);
        }
示例#4
0
        protected override void Because_of()
        {
            var thing = new Thing {
                Items = new[] { new Item() }
            };

            _thingDto = Mapper.Map <Thing, ThingDto>(thing);
        }
示例#5
0
        public ThingUpdatePage(MainWindow mainWindow)
        {
            if (thingRest == null)
            {
                thingRest = new ThingRest();
            }

            InitializeComponent();
            this.mainWindow = mainWindow;

            currentThing              = thingRest.Get(mainWindow.currentId);
            nameTextBox.Text          = currentThing.Name;
            defaultPriceTextBox.Text  = currentThing.DefaultPrice.ToString();
            neededCheckBox.IsChecked  = currentThing.Needed;
            householdIdTextBlock.Text = currentThing.HouseholdId.ToString();
        }
        public void Get_Ok()
        {
            //  Arrange
            var logic = Mocks.GetMockedLogic();

            //  Act
            ThingDto dto = logic.GetById(1);

            //  Assert
            Assert.IsTrue(
                dto.DefaultPrice == Mocks.TestThing1.DefaultPrice &&
                dto.ThingId == Mocks.TestThing1.ThingId &&
                dto.Show == Mocks.TestThing1.Show &&
                dto.Needed == Mocks.TestThing1.Needed &&
                dto.Name == Mocks.TestThing1.Name &&
                dto.HouseholdId == Mocks.TestThing1.HouseholdId &&
                dto.Household.GetType() == typeof(LinkDto));
        }
        private void createBtn_Click(object sender, RoutedEventArgs e)
        {
            if (nameTextBox.Text == "" || householdIdTextBox.Text == "")
            {
                MessageBox.Show("Name and Household ID are required.");
            }
            else
            {
                int    householdId  = 0;
                double defaultPrice = 0;

                try
                {
                    householdId = Int32.Parse(householdIdTextBox.Text);
                }
                catch (FormatException a)
                {
                    MessageBox.Show("Household ID must be a number.");
                }

                if (defaultPriceTextBox.Text != "")
                {
                    try
                    {
                        defaultPrice = Double.Parse(defaultPriceTextBox.Text);
                    }
                    catch (FormatException a)
                    {
                        MessageBox.Show("Default Price must be a number.");
                    }
                }

                ThingDto thing = new ThingDto()
                {
                    Name         = nameTextBox.Text,
                    HouseholdId  = householdId,
                    Needed       = (bool)neededCheckBox.IsChecked,
                    DefaultPrice = defaultPrice,
                    Show         = true,
                };

                thingRest.Create(thing);
            }
        }
 protected override void Because_of()
 {
     var thing = new Thing { Items = new[] { new Item() } };
     _thingDto = Mapper.Map<Thing, ThingDto>(thing);
 }
示例#9
0
        private void updateBtn_Click(object sender, RoutedEventArgs e)
        {
            ThingDto thing = (ThingDto)myDataGrid.SelectedItem;

            mainWindow.GoToThingUpdatePage(thing.ThingId);
        }
示例#10
0
        private void deleteBtn_Click(object sender, RoutedEventArgs e)
        {
            ThingDto thing = (ThingDto)myDataGrid.SelectedItem;

            thingRest.Delete(thing.ThingId);
        }
 public IActionResult Test2([FromBody] ThingDto thing)
 {
     return(Ok($"received: {thing.Name}"));
 }
示例#12
0
 public ActionResult Create(ThingDto dto)
 {
     return(View("Create"));
 }