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")); }
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")); }
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")); }