private void ProcessIncommingBug(string msg) { using (var scope = scopeFactory.CreateScope()) { log.Debug("New Bug arrived " + msg); BugMessage bm = JsonConvert.DeserializeObject <BugMessage>(msg); var repositoryScope = scope.ServiceProvider.GetRequiredService <IRepository <OrganizationCost> >(); var now = DateTime.Now; try { var ocost = repositoryScope.GetFirst(x => x.Month == now.Month && x.Year == now.Year && x.OrganizationId == bm.message.organizationId); //ESTA - HAY Q ACTUALIZAR ocost.BugsAmount = ocost.BugsAmount + 1; repositoryScope.Update(ocost); } catch (InvalidOperationException) { //NO ESTA - HAY QUE AGREGAR LA TUPLA OrganizationCost oc = new OrganizationCost() { BugsAmount = 1, Month = now.Month, Year = now.Year, OrganizationId = bm.message.organizationId, UsersAmount = 0 }; repositoryScope.Add(oc); } repositoryScope.Save(); } }
public void ExecuteBug(BugMessage message) { var client = new ClientModel().Collection().Find(x => x.ClientID.Equals(message.ClientID)).FirstOrDefault(); message.BugInfo.Client = client; message.BugInfo.Collection().InsertOne(message.BugInfo); }