public Object GetMemberAttendence([FromBody] AttendenceInput ai) { AttendenceAllOutput AAOP = new AttendenceAllOutput(); DataSet ds_SlotBooking = new DataSet(); string sJSONResponse = ""; DataTable dt_AttendenceAggregatePresent = new DataTable(); dt_AttendenceAggregatePresent = getdata(string.Format("SELECT count(*) as NoOfDaysPresent FROM (SELECT ROW_NUMBER() OVER(PARTITION BY UCode,convert(date,DateOfTransaction) ORDER BY UCode,convert(date,DateOfTransaction) DESC) AS StRank, * FROM DailyAttendence) n WHERE StRank IN (1) and UCode='{0}' and DateOfTransaction between '{1}' and '{2}' ", ai.MembershipCode, ai.StartDate, ai.EndDate)); double TotalNoDays = ai.EndDate.Subtract(ai.StartDate).Days; double NoOfDaysPresent = Convert.ToDouble(dt_AttendenceAggregatePresent.Rows[0]["NoOfDaysPresent"]); double CompleteDivided = NoOfDaysPresent / TotalNoDays; double PresentPercentage = CompleteDivided * 100; try { List <Attendenceobjects> attReport = new List <Attendenceobjects>(); Attendenceobjects dashboardlist = new Attendenceobjects { Attendence = GetDateWiseAttendence(ai.MembershipCode, ai.StartDate, ai.EndDate), TotalNoDays = Math.Round(TotalNoDays), NoOfDaysPresent = Math.Round(NoOfDaysPresent), PresentPercentage = Math.Round(PresentPercentage) }; attReport.Add(dashboardlist); AAOP.status = "success"; AAOP.value = attReport; sJSONResponse = JsonConvert.SerializeObject(AAOP); } catch (Exception ec) { } return(sJSONResponse); }
public Object DailyAttendencePost([FromBody] AttendenceInput ai) { string sJSONResponse = ""; DataTable dt_AppType = new DataTable(); string ServerDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture); int a = 0; string olPackage_Query = ""; AttendenceOutput aop = new AttendenceOutput(); try { cnn.Open(); olPackage_Query = "insert into DailyAttendence(SourceId,OrgId,MachineId,UCode,UName,DateOfTransaction,CreatedOn) values('1','" + ai.BranchCode + "','" + ai.MachineId + "','" + ai.MembershipCode + "','" + ai.UserName + "','" + ai.DateOfTransaction + "','" + ServerDateTime + "') SELECT @@IDENTITY;"; SqlCommand tm_cmd = new SqlCommand(olPackage_Query, cnn); a = Convert.ToInt32(tm_cmd.ExecuteScalar()); aop.status = "Success"; aop.value = Convert.ToString(a); } catch (Exception ex) { aop.status = "Fail"; } finally { cnn.Close(); } sJSONResponse = JsonConvert.SerializeObject(aop); return(sJSONResponse); }