public JsonResult <List <AssessmentTypeViewModel> > GetAllAssessmentTypeData(AssessmentTypeViewModel objAssessmentTypeModel) { try { var record = _iAssessmentType.GetAllAssessmentTypeData(objAssessmentTypeModel); return(Json(record)); } catch (Exception ex) { Common.MyLogger.Error(ex.Message + ex.StackTrace + ex.InnerException.ToString()); return(null); } }
public async Task<JsonResult> Create(AssessmentTypeViewModel collection) { try { collection.CreatedDate = DateTime.Now; collection.ModifiedDate = DateTime.Now; var stringContent = new StringContent(JsonConvert.SerializeObject(collection).ToString(), Encoding.UTF8, "application/json"); var status = await service.Save(stringContent); return new JsonResult { Data = new { status = status } }; } catch (Exception ex) { return new JsonResult { Data = new { status = false } }; } }
/// <summary> /// GetBy Id /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <AssessmentTypeViewModel> GetById(int id) { var masterTable = new AssessmentTypeViewModel(); using (var client = Common.GetHttpClient()) { var Response = await client.GetAsync(AdminConstants.ASSESSMENTTYPE_API_GET + "?id=" + id); if (Response.IsSuccessStatusCode) { return(JsonConvert.DeserializeObject <AssessmentTypeViewModel>(Response.Content.ReadAsStringAsync().Result)); } return(null); } }
/// <summary> /// Get All AssessmentType Data /// </summary> /// <param name="objAssessmentTypeModel"></param> /// <returns></returns> public List <AssessmentTypeViewModel> GetAllAssessmentTypeData(AssessmentTypeViewModel objAssessmentTypeModel) { List <AssessmentTypeViewModel> getAssessmentTypeModelList = new List <AssessmentTypeViewModel>(); GEEDbContext context = new GEEDbContext(); var _assessmentTypeData = (from mstTbl in context.AssessmentTYPEs //join mng in context.MasterTables on mstTbl.AssessmentGroup_ID equals mng.MasterTable_id where mstTbl.IsDeleted != true select new { mstTbl.AssessmentType_Id, mstTbl.AssessmentType_code, mstTbl.AssessmentType_Name, mstTbl.MinMarks, mstTbl.MaxMarks, mstTbl.PassingMarks, mstTbl.Weightage }); //Sorting if (!(string.IsNullOrEmpty(objAssessmentTypeModel.SortColumn) && string.IsNullOrEmpty(objAssessmentTypeModel.SortOrder))) { _assessmentTypeData = _assessmentTypeData.OrderBy(objAssessmentTypeModel.SortColumn + " " + objAssessmentTypeModel.SortOrder); } int recordsTotal = _assessmentTypeData.Count(); var data = _assessmentTypeData.Skip(objAssessmentTypeModel.PageNo).Take(objAssessmentTypeModel.PageSize).ToList(); foreach (var item in data) { AssessmentTypeViewModel objMasterModel = new AssessmentTypeViewModel(); objMasterModel.AssessmentType_Id = item.AssessmentType_Id; objMasterModel.AssessmentType_code = item.AssessmentType_code; objMasterModel.AssessmentType_Name = item.AssessmentType_Name; objMasterModel.MinMarks = item.MinMarks; objMasterModel.MaxMarks = item.MaxMarks; objMasterModel.PassingMarks = item.PassingMarks; objMasterModel.Weightage = item.Weightage; objMasterModel.RowCount = recordsTotal; getAssessmentTypeModelList.Add(objMasterModel); } return(getAssessmentTypeModelList); }