public ActionResult Index() { var nhom = NhomCoQuanRepository.GetAll().Select(x => x.ToIfNotNullDataInfo()); var model = new CoQuanViewModel { NhomCoQuanInfos = nhom }; return(View(model)); }
public async Task <JsonResult> Create(CoQuanViewModel model) { return(await ExecuteWithErrorHandling(async() => { var result = model.ToDataResult <CoQuanResult>().Update(u => { u.NhomCoQuanId = model.NhomCoQuanId; u.CreatedBy = UserName; }); return await ExecuteResultAsync(async() => await CoQuanRepository.AddAsync(result)); })); }
public async Task <JsonResult> Edit(int id, CoQuanViewModel model) { return(await ExecuteWithErrorHandling(async() => { var cv = model.ToDataResult <CoQuanResult>().Update(u => { u.Id = id; u.NhomCoQuanId = model.NhomCoQuanId; u.LastUpdatedBy = UserName; }); return await ExecuteResultAsync(async() => await CoQuanRepository.UpdateAsync(cv)); })); }