public ActionResult Add(ActivityView activityView) { if (ModelState.IsValid) { IActivitiesRepository activitiesRepository = new ActivitiesRepository(db); Activity activity = new Activity(); activityView.ConvertTo(activityView, activity); activitiesRepository.Add(activity); activitiesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("INSERT", activity.ActivityPK); return(RedirectToAction("Index", "Activity")); } else { return(View(activityView)); } }
// api/activities public IActionResult AddActivity(Activity activity) { _repo.Add(activity); return(Created($"api/activity/{activity.Id})", activity)); }