Beispiel #1
0
        public void CreateAndReadEntity()
        {
            _sut.Add(MockObjects.Message);
            TextMessage newMessage = _sut.Find(x => x.Date == MockObjects.Message.Date);

            MockObjects.Message.Id = newMessage.Id;

            newMessage.Should().NotBeNull();
            newMessage.Should().BeEquivalentTo(MockObjects.Message);
        }
Beispiel #2
0
        public void AddStatement()
        {
            _persistence.Add(GetCurrentStatementState());
            CurrentNumber++;

            CurrentStatement.Text   = "";
            CurrentStatement.IsTrue = false;

            NotifyOfPropertyChange(() => CurrentStatement);
        }
 public ActionResult Create(IFormCollection collection)
 {
     try
     {
         if (collection["ComputerType"] == "Desktop PC")
         {
             var model = computerPersistenceService.Load();
             computerPersistenceService.Add(new Computer
             {
                 Id           = int.Parse(collection["Id"]),
                 ComputerType = collection["ComputerType"],
                 Processor    = collection["Processor"],
                 Brand        = collection["Brand"],
                 UsbPorts     = int.Parse(collection["UsbPorts"]),
                 RamSlots     = int.Parse(collection["RamSlots"]),
                 FormFactor   = collection["FormFactor"],
                 Quantity     = int.Parse(collection["Quantity"])
             });
         }
         else
         {
             var model = laptopPersistenceService.Load();
             laptopPersistenceService.Add(new Laptop
             {
                 Id           = int.Parse(collection["Id"]),
                 ComputerType = collection["ComputerType"],
                 Processor    = collection["Processor"],
                 Brand        = collection["Brand"],
                 UsbPorts     = int.Parse(collection["UsbPorts"]),
                 RamSlots     = int.Parse(collection["RamSlots"]),
                 FormFactor   = collection["FormFactor"],
                 Quantity     = int.Parse(collection["Quantity"]),
                 ScreenSize   = collection["ScreenSize"]
             });
         }
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
Beispiel #4
0
 public Medicine Add(Medicine medicine)
 {
     _persistence.Add(medicine);
     return(medicine);
 }