public async Task <ActionResult> View(long?cal_id) { if (cal_id != null) { CalendarUpdateViewModel model = new CalendarUpdateViewModel(); var postTask = await client.GetAsync("/api/Calendar/View/?cal_id=" + cal_id); model = await postTask.Content.ReadAsAsync <CalendarUpdateViewModel>(); if (model != null) { return(View("View", model)); } else { CalendarIndexViewModel data = new CalendarIndexViewModel(); ViewBag.Error = "No Activity Found !"; return(View("Index", data)); } } return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); }
public async Task <ActionResult> Edit(CalendarUpdateViewModel data) { if (ModelState.IsValid) { try { data.active = true; data.modifiedBy = Session["user_id"].ToString(); data.modifiedDateTime = DateTime.Now; List <CalendarCompanySetup> elements = new List <CalendarCompanySetup>(); { foreach (CalendarCompanySetup dp in data.companies) { elements.Add(new CalendarCompanySetup() { comp_id = dp.comp_id, modifiedDateTime = DateTime.Now, modifiedBy = Session["user_id"].ToString() }); } } data.companies = elements; var postTask = await client.PostAsJsonAsync("/api/Calendar/Update", data); if (postTask.IsSuccessStatusCode) { return(Json(true, JsonRequestBehavior.DenyGet)); } } catch (Exception) { return(Json(false, JsonRequestBehavior.DenyGet)); } } return(Json(false, JsonRequestBehavior.DenyGet)); }