public async Task <ActionResult> ChangeStatus(VTask vTask) { Kid currentKid = await _kidRepository.GetProfileById(vTask.KidId); if (ModelState.IsValid) { vTask.Done = !vTask.Done; _vTaskRepository.Update(vTask); await _vTaskRepository.CommitAsync(); if (!vTask.Done) { currentKid.TotalPoint -= vTask.Point; } else { currentKid.TotalPoint += vTask.Point; } _kidRepository.Update(currentKid); await _kidRepository.CommitAsync(); var toastobj = Helper.getToastObj("Task complete status updated!", "alert-success"); TempData.Put("toast", toastobj); return(RedirectToAction("Details", "Kid", new { vTask.KidId })); } return(View(vTask)); }
public ActionResult Create(int KidId) { VTask vTask = new VTask() { KidId = KidId }; return(View(vTask)); }
public async Task <ActionResult> Edit(VTask vTask) { if (ModelState.IsValid) { _vTaskRepository.Update(vTask); await _vTaskRepository.CommitAsync(); var toastobj = Helper.getToastObj("Task was sucessfully updated!", "alert-success"); TempData.Put("toast", toastobj); return(RedirectToAction("Details", "Kid", new { vTask.KidId })); } return(View(vTask)); }
public async Task <ActionResult> Create(VTask vTask) { Kid currentKid = await _kidRepository.GetProfileById(vTask.KidId); if (ModelState.IsValid) { VTask newVTask = new VTask { Description = vTask.Description, Point = vTask.Point, Kid = currentKid }; _vTaskRepository.Add(newVTask); await _vTaskRepository.CommitAsync(); var toastobj = Helper.getToastObj("Task was successfully created!", "alert-success"); TempData.Put("toast", toastobj); return(RedirectToAction("Details", "Kid", new { vTask.KidId })); } return(View(vTask)); }