Exemplo n.º 1
0
        public ActionResult Create(DogEvent model, string eventTime)
        {
            var timespan = TimeParserHelper.Parse(eventTime);

            if (!timespan.HasValue)
            {
                // this will trigger ModelState being invalid below
                ModelState.AddModelError("EventTime", "Please enter a valid time.");
            }

            if (!ModelState.IsValid)
            {
                var dog = _dogProfileRepo.GetById(model.DogProfileID);

                SetDogViewBag(dog);

                ViewBag.EventTypeSelectList = new SelectList(_eventTypesRepo.GetAll(), "ID", "Name", null);

                return View(model);
            }

            model.EventDate = model.EventDate.Add(timespan.Value);

            _dogEventsRepo.Insert(model);

            return RedirectToAction("Index", new { dog = model.DogProfileID });
        }
Exemplo n.º 2
0
        public ActionResult Create(DogProfile dog)
        {
            // verify dog exists
            if (dog == null)
                return RedirectToAction("Index", "Dog");

            SetDogViewBag(dog);

            ViewBag.EventTypeSelectList = new SelectList(_eventTypesRepo.GetAll(), "ID", "Name", null);

            var model = new DogEvent
            {
                DogProfileID = dog.ProfileID,
                EventDate = DateTime.Now.Date
            };

            return View(model);
        }
Exemplo n.º 3
0
 public ActionResult CreateOrUpdateDogEvent(DogEvent dogEvent)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 4
0
        public ActionResult CreateOrUpdateDogEvent(DogEvent dogEvent)
        {                

            var user = _userRepo.Where(u => u.Email == this.HttpContext.User.Identity.Name).FirstOrDefault();

            if (user.IsUserAdminOrTrainer())
            {

                if (dogEvent.EventID == 0)
                {
                    _dogEventRepo.Insert(dogEvent);
                }
                else
                {
                    _dogEventRepo.Update(dogEvent);
                }
                return RedirectToAction("ReadDog", new { id = dogEvent.DogProfileID });
            }

            return RedirectToAction("Error403", "Error");
        }