public async Task <ProjectDetalInfoViewModel> GetProjectDetalInfoAsync(int projectId) { var content = await client.GetStringAsync($"api/ProjectDetalInfo/{projectId}").ConfigureAwait(false); ProjectDetalInfoViewModel project = await Task.Run(() => JsonConvert.DeserializeObject <ProjectDetalInfoViewModel>(content)).ConfigureAwait(false); return(project); }
public async Task <ActionResult> ProjectDetalInfoEdit(List <HttpPostedFileBase> files, ProjectDetalInfoViewModel projectInfo) { var volid = ModelState.IsValid; if (projectInfo.Title != null && projectInfo.Title.Trim().Length > 0 && projectInfo.Description != null && projectInfo.Description.Trim().Length > 0) { foreach (var item in files) { if (item == null) { break; } byte[] bytes = null; using (BinaryReader br = new BinaryReader(item.InputStream)) { bytes = br.ReadBytes(item.ContentLength); } projectInfo.Files.Add(new FileViewModel { FileName = item.FileName, FileType = item.ContentType, File = bytes }); } projectInfo.Files.Remove(null); var data = Newtonsoft.Json.JsonConvert.SerializeObject(projectInfo); if (data != null) { await DataStore.UpdateProjectAsync(data); } var items = await DataStore.GetTypesAsync(); return(View("Index", items)); } return(View(projectInfo)); }