Beispiel #1
0
        public IActionResult Add(AddViewModel newPlant)
        {
            Plant addPlant = new Models.Plant
            {
                Name   = newPlant.Name,
                Seeded = newPlant.Seeded,
                Ready  = newPlant.Ready,
                Price  = newPlant.Price
            };

            context.Plants.Add(addPlant);
            context.SaveChanges();



            return(Redirect("/"));
        }
Beispiel #2
0
        public IActionResult Add(AddPlantViewModel addPlantViewModel)
        {
            if (ModelState.IsValid)
            {
                PlantRooms thePlantRoom = context.PlantRooms.Find(addPlantViewModel.PlantRoomId);
                Plant      newPlant     = new Plant
                {
                    PlantName      = addPlantViewModel.PlantName,
                    PlantGenus     = addPlantViewModel.PlantGenus,
                    LastWatered    = addPlantViewModel.LastWatered,
                    LastFertilized = addPlantViewModel.LastFertilized,
                    PlantRoom      = thePlantRoom
                };

                context.Plants.Add(newPlant);
                context.SaveChanges();

                return(Redirect("/Plants"));
            }

            return(View(addPlantViewModel));
        }
Beispiel #3
0
        public IActionResult Create(AddReminderViewModel addReminderViewModel)
        {
            if (ModelState.IsValid)
            {
                Plant    thePlant    = context.Plants.Find(addReminderViewModel.PlantId);
                Reminder newReminder = new Reminder
                {
                    Email   = addReminderViewModel.EmailAddress,
                    Message = addReminderViewModel.Message,
                    Time    = addReminderViewModel.ReminderTime,
                    Plant   = thePlant
                };

                context.Reminders.Add(newReminder);
                _backgroundJobClient.Schedule <EmailService>(x => x.SendReminderAsync(newReminder), new
                                                             DateTimeOffset(newReminder.Time));
                context.SaveChanges();

                return(Redirect("/Reminders"));
            }

            return(View(addReminderViewModel));
        }
Beispiel #4
0
        public IActionResult Create(AddPlantRoomViewModel addPlantRoomViewModel)
        {
            if (ModelState.IsValid)
            {
                PlantRooms newPlantRoom = new PlantRooms
                {
                    Name = addPlantRoomViewModel.Name
                };

                context.PlantRooms.Add(newPlantRoom);
                context.SaveChanges();

                return(Redirect("/PlantRoom"));
            }

            return(View(addPlantRoomViewModel));
        }