public JsonResult ReportOnline(ReportOnlineViewModel reportOnlineViewModel) { try { var token = _tokenValidator.Validate(HttpContext); if (!token.Success) { return(Json(new ReturnData <string> { Success = false, NotAuthenticated = true, Message = $"Unauthorized:-{token.Message}", })); } if (token.Role != Role.Student) { return(Json(new ReturnData <string> { Success = false, NotAuthenticated = true, Message = "Sorry, you are not authorized to perform this action", })); } var classStatus = _context.Settings.FirstOrDefault()?.ClassStatus; var hostelrooms = _unisolApiProxy.ReportOnline(reportOnlineViewModel, classStatus).Result; var jdata = JsonConvert.DeserializeObject <ReturnData <dynamic> >(hostelrooms); if (!jdata.Success) { return(Json(new ReturnData <bool> { Success = false, Message = jdata.Message })); } return(Json(new ReturnData <List <HostelRooms> > { Success = true, Message = jdata.Message })); } catch (Exception ex) { return(Json(new ReturnData <string> { Success = false, Message = "Oops,An error occured while trying saving your reporting, please try again " + ErrorMessangesHandler.ExceptionMessage(ex) })); } }
public JsonResult AddOnlineReporting(ReportOnlineViewModel reportOnlineModel, string classStatus) { var sysSetup = _context.SysSetup.FirstOrDefault(); if (sysSetup.ReportingDeadline.Date < DateTime.UtcNow.Date) { return(Json(new ReturnData <OnlineReporting> { Success = false, Message = "Sorry, Your reporting deadline has expired, Please contact School Admin. ", })); } var plannerDetails = _studentServices.GetSessionPlannerCurrentDetails(reportOnlineModel.UserCode, classStatus); if (!plannerDetails.Success) { return(Json(new ReturnData <OnlineReporting> { Success = plannerDetails.Success, Message = plannerDetails.Message, })); } var currentTerm = _studentServices.GetCurrentTerm(reportOnlineModel.UserCode, classStatus); if (!currentTerm.Success) { return(Json(currentTerm)); } var erpReporting = _studentServices.CheckErpReporting(reportOnlineModel.UserCode, classStatus); if (erpReporting.Success) { return(Json(new ReturnData <bool> { Success = false, Message = erpReporting.Message })); } var onlineReporting = _studentServices.CheckOnlineReporting(reportOnlineModel.UserCode, classStatus); if (onlineReporting.Success) { return(Json(new ReturnData <bool> { Success = false, Message = onlineReporting.Message })); } var hasReported = studentCredentials.ValidateSessionReporting(reportOnlineModel.UserCode, classStatus); if (hasReported.Success) { return(Json(hasReported)); } _context.OnlineReporting.Add( new OnlineReporting { Term = currentTerm.Data.Names, AdmnNo = reportOnlineModel.UserCode, Personnel = reportOnlineModel.UserCode, Rdate = DateTime.Today, Status = "Pending" } ); _context.SaveChanges(); return(Json(new ReturnData <bool> { Success = true, Message = "You have successfully reported to current semester (" + currentTerm + ")" })); }
public Task <string> ReportOnline(ReportOnlineViewModel reportOnlineViewModel, string classStatus) { var response = Post("onlinereporting/AddOnlineReporting/?classStatus=" + classStatus, reportOnlineViewModel); return(response); }