public ServerResponse AddScheduleItem(ScheduleItem p_scheduleItem)
 {
     try
     {
         _serviceProvider.repo.Add(p_scheduleItem);
         return(ServerResponse.Ok(p_scheduleItem.Id));
     }
     catch (Exception e)
     {
         return(ServerResponse.Fail(e.ToString()));
     }
 }
 public ServerResponse Get(Guid id)
 {
     try
     {
         var stats = _statsService.GetSessionStats(id);
         return(ServerResponse <SessionStats> .Success(stats));
     }
     catch (Exception exception)
     {
         return(ServerResponse.Fail(exception.Message));
     }
 }
 public ServerResponse GetScheduleItem(int p_id)
 {
     try
     {
         var scheduleItem = _serviceProvider.repo.FirstOrDefault(item => item.Id == p_id);
         return(ServerResponse.Ok(scheduleItem));
     }
     catch (Exception e)
     {
         return(ServerResponse.Fail(e.ToString()));
     }
 }
 public ServerResponse Delete(Guid id)
 {
     try
     {
         _wordsService.CloseSession(id);
         return(ServerResponse.Success());
     }
     catch (Exception exception)
     {
         return(ServerResponse.Fail(exception.Message));
     }
 }
 public ServerResponse Post()
 {
     try
     {
         var sessionId = _wordsService.OpenSession();
         return(ServerResponse <Guid> .Success(sessionId));
     }
     catch (Exception exception)
     {
         return(ServerResponse.Fail(exception.Message));
     }
 }
 public ServerResponse Post([FromBody] PostWords postedWords)
 {
     try
     {
         _wordsService.AddWord(postedWords.SessionId, postedWords.Words);
         _statsService.WordsSubmitted(postedWords.SessionId, postedWords.Words.Length, GetClientIp());
         return(ServerResponse.Success());
     }
     catch (Exception exception)
     {
         return(ServerResponse.Fail(exception.Message));
     }
 }
 public ServerResponse Get(Guid sessionId, string word)
 {
     try
     {
         var count = _wordsService.CountWord(sessionId, word);
         _statsService.RequestPerformed(sessionId, GetClientIp());
         return(ServerResponse <long> .Success(count));
     }
     catch (Exception exception)
     {
         return(ServerResponse.Fail(exception.Message));
     }
 }
        public ServerResponse RemoveScheduleItem(int p_id)
        {
            var itemToRemove = _serviceProvider.repo.Single(item => item.Id == p_id);

            try
            {
                _serviceProvider.repo.Remove(itemToRemove);
                return(ServerResponse.Ok(p_id));
            }
            catch (Exception e)
            {
                return(ServerResponse.Fail(e.ToString()));
            }
        }
 public ServerResponse Get(Guid sessionId)
 {
     try
     {
         var words = _wordsService.CountWords(sessionId)
                     .Select(c => new WordEntry()
         {
             Word = c.Key, Count = c.Value
         })
                     .ToArray();
         _statsService.RequestPerformed(sessionId, GetClientIp());
         return(ServerResponse <WordEntry[]> .Success(words));
     }
     catch (Exception exception)
     {
         return(ServerResponse.Fail(exception.Message));
     }
 }