Beispiel #1
0
    //method to create a log.
    public async Task <string> CreateLog(TimeLogging timeLogging)
    {
        var issue = this_dataBaseContext.IssueList.Where(i => i.issueId == timeLogging.issueId).ToList();

        if (issue.Count == 0)
        {
            return(await Task.FromResult("Invalid issue id"));
        }
        this_dataBaseContext.TimeLoggings.Add(timeLogging);
        this_dataBaseContext.SaveChanges();
        return(await Task.FromResult($"New Time log created for issue with id = {timeLogging.issueId}."));
    }
Beispiel #2
0
 public TimeLogging AddTimeLog(string logCreater, int logTime, int issueId)
 {
     using (var db = new StoreContext())
     {
         var issue = db.IssueList.Find(issueId);
         if (issue == null)
         {
             return(null);
         }
         var newTimeLog = new TimeLogging {
             logCreater = logCreater, logTime = logTime, issueId = issueId
         };
         db.TimeLoggings.Add(newTimeLog);
         db.SaveChanges();
         return(newTimeLog);
     }
 }
Beispiel #3
0
 public async Task <IActionResult> CreateLog(TimeLogging timeLogging)
 {
     timeLogging.logCreater = _httpContextAccessor.HttpContext?.User?.Claims.Where(a => a.Type == ClaimTypes.Name).FirstOrDefault()?.Value;
     return(Ok(await _timeLoggingRepository.CreateLog(timeLogging)));
 }