public IHttpActionResult GetComplainReport(DateTime fromDate, DateTime toDate) { try { List <ComplainReportViewModel> complainList = new List <ComplainReportViewModel>(); IEnumerable <Complain> complains = new List <Complain>(); complains = _complain.GetAllComplains(fromDate, toDate); if (complains.Count() > 0) { foreach (Complain complain in complains) { if (complain.DriverId != null) { foreach (ComplainCategory category in complain.ComplainCategories) { if (category.IsSelected == true) { ComplainReportViewModel complainView = new ComplainReportViewModel(); complainView.driverName = _member.GetMember(complain.DriverId.Value).FullName; complainView.ntcNo = _member.GetMember(complain.DriverId.Value).NTCNo; complainView.complain = String.IsNullOrEmpty(category.Category.Description) ? String.Empty : category.Category.Description; complainView.complainStatus = complain.ComplainStatus; complainList.Add(complainView); } } } if (complain.ConductorId != null) { foreach (ComplainCategory category in complain.ComplainCategories) { if (category.IsSelected == true) { ComplainReportViewModel complainView = new ComplainReportViewModel(); complainView.driverName = _member.GetMember(complain.ConductorId.Value).FullName; complainView.ntcNo = _member.GetMember(complain.ConductorId.Value).NTCNo; complainView.complain = String.IsNullOrEmpty(category.Category.Description) ? String.Empty : category.Category.Description; complainView.complainStatus = complain.ComplainStatus; complainList.Add(complainView); } } } } } var messageData = new { code = Constant.SuccessMessageCode, message = Constant.MessageSuccess }; var returnObject = new { complainList = complainList, messageCode = messageData }; return(Ok(returnObject)); } catch (Exception ex) { string errorLogId = _eventLog.WriteLogs(User.Identity.Name, ex, MethodBase.GetCurrentMethod().Name); var messageData = new { code = Constant.ErrorMessageCode, message = String.Format(Constant.MessageTaskmateError, errorLogId) }; var returnObject = new { messageCode = messageData }; return(Ok(returnObject)); } }
public IHttpActionResult GetAllComplainsByMember(int memberId) { try { List<CategoryViewModel> categoryList = new List<CategoryViewModel>(); List<ComplainDescViewModel> complainDesc = new List<ComplainDescViewModel>(); IEnumerable<Complain> complains = new List<Complain>(); complains = _complain.GetAllComplains(memberId); if (complains != null) { foreach (Complain complain in complains) { foreach (ComplainCategory category in complain.ComplainCategories) { if (categoryList.Find(x=>x.categoryNo == category.Category.CategoryNo) == null && category.IsSelected == true) { CategoryViewModel complainCategory = new CategoryViewModel(); complainCategory.id = category.ComplainId; complainCategory.categoryNo = String.IsNullOrEmpty(category.Category.CategoryNo) ? String.Empty : category.Category.CategoryNo; complainCategory.description = String.IsNullOrEmpty(category.Category.Description) ? String.Empty : category.Category.Description; categoryList.Add(complainCategory); } } ComplainDescViewModel desc = new ComplainDescViewModel(); desc.id = complain.ID; desc.complainNo = complain.ComplainNo; desc.description = String.IsNullOrEmpty(complain.Description) ? String.Empty : complain.Description; complainDesc.Add(desc); } } var messageData = new { code = Constant.SuccessMessageCode, message = Constant.MessageSuccess }; var returnObject = new { complainsCategory = categoryList, complainsDescList = complainDesc, messageCode = messageData }; return Ok(returnObject); } catch (Exception ex) { string errorLogId = _eventLog.WriteLogs(User.Identity.Name, ex, MethodBase.GetCurrentMethod().Name); var messageData = new { code = Constant.ErrorMessageCode, message = String.Format(Constant.MessageTaskmateError, errorLogId) }; var returnObject = new { messageCode = messageData }; return Ok(returnObject); } }