public ActionResult IndexAsync(SpreadSheetUpdateViewModel model) { if (ModelState.IsValid && SpreadSheetHelper.UpdateSpreadSheet(model.SelectedUser, model.SelectedWorksheetId, model.SelectedExpenditureType, model.SelectedAmount)) { ModelState.Clear(); ViewBag.Title = "Success"; return View(SpreadSheetUpdateViewModel.GetModel()); } ViewBag.Title = "Failed"; return View(SpreadSheetUpdateViewModel.GetErrorModel()); }
public static SpreadSheetUpdateViewModel GetModel() { var spreadSheet = SpreadSheetHelper.GetSpreadSheet(WebConfigurationManager.AppSettings["SpreadsheetURI"]); var worksheets = SpreadSheetHelper.GetWorkSheets(spreadSheet); var tempWorkSheet = spreadSheet.Worksheets.Entries[0]; AtomLink listFeedLink = tempWorkSheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null); ListQuery listQuery = new ListQuery(listFeedLink.HRef.ToString()); ListFeed listFeed = SpreadSheetHelper.Query(listQuery); var expenditureTypes = GetExpenditureTypes(listFeed); var users = new List<SelectListItem> { new SelectListItem { Text = "Henri", Value = "Henri" }, new SelectListItem { Text = "Fredrik", Value = "Fredrik" } }; var model = new SpreadSheetUpdateViewModel { Worksheets = worksheets, SpreadsheetTitle = spreadSheet.Title.Text, ExpenditureTypes = expenditureTypes, Users = users }; return model; }