예제 #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);
        }
예제 #2
0
        public void AddStatement()
        {
            _persistence.Add(GetCurrentStatementState());
            CurrentNumber++;

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

            NotifyOfPropertyChange(() => CurrentStatement);
        }
예제 #3
0
 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());
     }
 }
예제 #4
0
 public Medicine Add(Medicine medicine)
 {
     _persistence.Add(medicine);
     return(medicine);
 }