Example #1
0
        public async Task <ActionResult <CountDto> > GetCount()
        {
            var ret = new CountDto
            {
                TotalTweets = await _info.GetCount()
            };

            return(Ok(ret));
        }
Example #2
0
 public static void WriteCountLog(CountDto log)
 {
     try
     {
         SQLHelper sql    = new SQLHelper("DefaultConnection");
         string    strSql = string.Format(@"select id from [dbo].[Count]  WHERE BusId='{0}'", log.BusId);
         string    id     = sql.ExecuteReader(strSql);
         if (!string.IsNullOrEmpty(id))
         {
             strSql = string.Format(@"update [dbo].[Count] 
                                                         set sucsum='{0}',failsum='{1}',lattime='{2}',
                                                         succount=succount+{0},failcount=failcount+{1} 
                                                          where BusId='{3}'", log.sucsum, log.failsum, log.latTime, log.BusId);
             bool flag = sql.ExcuteNonQuery(CommandType.Text, strSql, null);
         }
         else
         {
             strSql = @"INSERT INTO [dbo].[Count]
                                            ([BusId]
                                            ,[sucsum]
                                            ,[failsum]
                                            ,[lattime]
                                            ,[succount]
                                            ,[failcount])
                                      VALUES
                                        (@BusId
                                        ,@sucsum
                                        ,@failsum
                                        ,@lattime
                                        ,@succount
                                        ,@failcount)";
             SqlParameter[] parm =
             {
                 new SqlParameter("@BusId",     log.BusId),
                 new SqlParameter("@sucsum",    log.sucsum),
                 new SqlParameter("@failsum",   log.failsum),
                 new SqlParameter("@lattime",   log.latTime),
                 new SqlParameter("@succount",  log.sucsum),
                 new SqlParameter("@failcount", log.failsum)
             };
             bool flag = sql.ExcuteNonQuery(CommandType.Text, strSql, parm);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #3
0
        public CountDto CountDb()
        {
            var studentC = from c in context.UserRoles
                           where c.RoleId == "3"
                           select c;

            var mentorC = from c in context.UserRoles
                          where c.RoleId == "2"
                          select c;

            CountDto countDto = new CountDto
            {
                Users        = context.MoDUsers.Count() - 1,
                Courses      = context.Courses.Count(),
                Students     = studentC.Count(),
                Mentors      = mentorC.Count(),
                Technologies = context.Technologies.Count()
            };

            return(countDto);
        }