예제 #1
0
        public ActionResult PostAttach([FromBody] PetActivityDTO value)
        {
            PetActivity petactivity = ToPetActivity.DividePetActivity(value);

            _petActivityRepository.Insert(petactivity);

            if (_petActivityRepository.Save())
            {
                return(Ok(new { petid = value.PetId, activityid = value.ActivityId }));
            }

            return(Ok("eroare"));
        }
예제 #2
0
        public ActionResult <Pet> GetPetActivities(int id)
        {
            List <PetActivity> activities = _petActivityRepository.GetPetActivities(id);

            var petactivities = new List <PetActivityDTO>();

            foreach (PetActivity act in activities)
            {
                PetActivityDTO aux = ToPetActivity.MergeObjects(act, act.Activity);
                petactivities.Add(aux);
            }

            if (petactivities != null)
            {
                return(Ok(petactivities));
            }

            return(Ok("eroare"));
        }
예제 #3
0
        public ActionResult Post([FromBody] PetActivityDTO value)
        {
            var activity    = ToPetActivity.DiviteActivity(value);
            var petactivity = ToPetActivity.DividePetActivity(value);

            petactivity.PetId = value.PetId;
            _activityRepository.Insert(activity);
            _activityRepository.Save();

            int activityId = _activityRepository.GetByTitleAndDescription(value.Title, value.Description, value.ExpPoints).ActivityId;

            petactivity.ActivityId = activityId;
            _petActivityRepository.Insert(petactivity);

            if (_petActivityRepository.Save())
            {
                return(Ok(new { petid = value.PetId, activityid = activityId }));
            }

            return(Ok("eroare"));
        }