public async Task AddProjectInfo( string repo, string commitSha, DateTimeOffset commitDate, ProjectInfo projectInfo) { var currentRepos = await dbContext.ProjectInfos .Where(pi => pi.Repo == repo) .AsNoTracking() .ToListAsync(); var hidden = currentRepos.SingleOrDefault(i => !i.IsPublic); if (hidden != null) { hidden.Commit = commitSha; hidden.CommitDate = commitDate; dbContext.Update(hidden); } else { hidden = new ProjectInfoRecord { Repo = repo, Commit = commitSha, CommitDate = commitDate, IsPublic = false }; dbContext.Add(hidden); } hidden.Info = projectInfo; await dbContext.SaveChangesAsync(); }
public async Task <ContactUsResponse> Post(CreateContactUsRequest request) { var proxyIp = HttpContext.Request.Headers["X-Real-IP"].ToString(); var senderIp = string.IsNullOrEmpty(proxyIp) ? HttpContext.Connection.RemoteIpAddress.ToString() : proxyIp; var createdModel = new Models.ContactUsMessage { Name = request.Name, Email = request.Email, Message = request.Message, SendTime = DateTime.UtcNow, SenderIp = senderIp }; landingDbContext.ContactUsMessages.Add(createdModel); await landingDbContext.SaveChangesAsync(); return(new ContactUsResponse { Name = createdModel.Name, Email = createdModel.Email, Message = createdModel.Message }); }