public async Task <ActionResult> Delete(MasterTableViewModel collection) { collection.ModifiedDate = DateTime.Now; var stringContent = new StringContent(JsonConvert.SerializeObject(collection).ToString(), Encoding.UTF8, "application/json"); var status = await service.Delete(stringContent); return(new JsonResult { Data = status, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public async Task <JsonResult> Index(string Id) { int masterTableTypeId; int.TryParse(Id, out masterTableTypeId); MasterTableViewModel collection = new MasterTableViewModel(); var draw = HttpContext.Request.Form["draw"].FirstOrDefault(); // Skiping number of Rows count var start = Request.Form["start"]; // Paging Length 10,20 var length = Request.Form["length"]; // Sort Column Name var sortColumn = Request.Form["columns[" + Request.Form["order[0][column]"].FirstOrDefault() + "][name]"]; // Sort Column Direction ( asc ,desc) var sortColumnDirection = Request.Form["order[0][dir]"]; // Search Value from (Search box) // var searchValue = Request.Form["search[value]"]; //Paging Size (10,20,50,100) int pageSize = length != null?Convert.ToInt32(length) : 0; int skip = start != null?Convert.ToInt32(start) : 0; int recordsTotal = 0; collection.PageNo = skip; collection.PageSize = pageSize; collection.SortOrder = sortColumnDirection; collection.SortColumn = sortColumn; collection.Mastertabletype_id = masterTableTypeId; var stringContent = new StringContent(JsonConvert.SerializeObject(collection).ToString(), Encoding.UTF8, "application/json"); var list = await service.GetAllMasterData(stringContent); if (list.Count > 0) { recordsTotal = list[0].RowCount; foreach (var item in list) { var parentName = list.Find(a => a.MasterTable_id == item.Parent_id); if (parentName != null) { item.ParentName = Convert.ToString(parentName.Name); } string defualtVal = item.IsDefault == true ? "Yes" : "No"; item.DefaultValue = defualtVal; } } // var data = list.Skip(skip).Take(pageSize).ToList(); return(Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = list })); }
public async Task <MasterTableViewModel> GetById(int id) { var masterTable = new MasterTableViewModel(); using (var client = Common.GetHttpClient()) { var Response = await client.GetAsync(AdminConstants.MASTERTABLE_API_GET_BY_ID + "id=" + id); if (Response.IsSuccessStatusCode) { return(JsonConvert.DeserializeObject <MasterTableViewModel>(Response.Content.ReadAsStringAsync().Result)); } return(null); } }
public async Task <ActionResult> Edit(MasterTableViewModel collection) { try { collection.ModifiedDate = DateTime.Now; var stringContent = new StringContent(JsonConvert.SerializeObject(collection).ToString(), Encoding.UTF8, "application/json"); var status = await service.Update(stringContent); return(new JsonResult { Data = new { status = status, IsSaved = true, Message = "Successfully Saved." } }); } catch (Exception ex) { return(new JsonResult { Data = new { status = true, IsSaved = false, Message = "Error" } }); } }