public virtual 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.GetValueOrDefault());

            _dogEventsRepo.Insert(model);

            return(RedirectToAction("Index", new { dog = model.DogProfileID }));
        }
Beispiel #2
0
        public ActionResult Edit(DogEvent model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            _dogEventsRepo.Update(model);

            return(RedirectToAction("Index", new { dogProfileId = model.DogProfileID }));
        }
Beispiel #3
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"));
        }
        public virtual ActionResult Create(DogProfile dog)
        // GET: /Events/Create/{dogProfileId}

        {
            // 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));
        }
        public IActionResult Add([FromBody] DogEventModel obj)
        {
            if (!IsCurrentUserAdmin() && !IsCurrentUserMember())
            {
                return(Forbid());
            }
            //dogs will be added to the event later
            var dogEvent = new DogEvent
            {
                DogId                  = obj.DogId,
                EventId                = obj.EventId,
                DogTrackBlobUrl        = obj.DogTrackBlobUrl,
                LostPerson             = obj.LostPerson,
                LostPersonTrackBlobUrl = obj.LostPersonTrackBlobUrl,
                Notes                  = obj.Notes,
                Weather                = obj.Weather
            };

            unitOfWork.DogEventRepository.Insert(dogEvent);
            unitOfWork.Commit();
            //var accessToken = HttpContext.GetTokenAsync("access_token").Result;

            return(new ObjectResult(new { eventId = dogEvent.EventId, dogId = dogEvent.DogId }));
        }
Beispiel #6
0
 public UnitTestDog()
 {
     dog = new DogEvent();
 }
Beispiel #7
0
 public ActionResult CreateOrUpdateDogEvent(DogEvent dogEvent)
 {
     throw new NotImplementedException();
 }