I am learning MVC and creating a project management site, and am stuck on a couple key ideas. I have a complex model, which includes a summary of the project, and a list of tasks
public class SummaryAndCategoriesViewModel
{
public Project Summary { get; set; }
public IEnumerable<task> Tasks { get; set; }
}
Inside the tasks, i've created an EditorTemplate, so that the user can switch each task state (from 'not started' -> 'completed'. for example)
In may main 'details' View, i have two partial views:
@{var categories = ViewData["AllCategories"] as List<Models.category>;}
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</div>
<div class="form-horizontal">
<hr />
<div class="Summary">
@Html.LabelFor(item => Model.Summary )
@{Html.RenderPartial("_Summary", Model.Summary);}
</div>
<hr />
<div class="tasks">
@Html.LabelFor(item => Model.Tasks )
@{Html.RenderPartial("_Task", Model.Tasks);}
</div>
</div>
}
What I'd ideally like is that the 'summary' loads in the normal details view, which it does, while the 'tasks' loads in an edit mode, which i've done as well.
As of now, i'm stuck on two things:
1- I would like to be able to change only the 'summary' partial view to edit somewhow (modal popup could work too), and still perform httpPosts. 2- I would like the user to be able to change the 'tasks' partial view, and by clicking save, update the tasks in the database and refresh the 'tasks' partial. I've been reading up on the partials and renderpartials, but i'm a bit confused on which method I should be using, how to return the partial models to the HTTPPost, and how to switch the partial views.
Any guidance would be greately appreciated