public IActionResult PostWithHistory(Puzzle puzzle) { UserProfile userProfile = GetCurrentUserProfile(); puzzle.CurrentOwnerId = userProfile.Id; puzzle.CreateDateTime = DateTime.Now; _puzzleRepository.Add(puzzle); History history = new History(); history.StartDateOwnership = DateTime.Now; history.PuzzleId = puzzle.Id; history.UserProfileId = userProfile.Id; _historyRepository.Add(history); return(CreatedAtAction("Get", new { id = puzzle.Id }, puzzle)); }
public History Add(int clientId, int bookId) { //daca clientul si cartea exista si cartea nu este data => adaugam un istoric cu datele furnizate si putem sa ii dam cartea clientului var client = clientRepository.GetById(clientId); var book = bookRepository.GetById(bookId); if (client == null || book == null) { return(null); } if (!client.IsDeleted && !book.IsDeleted && book.IsAvailable) { var history = new History() { ClientId = client.Id, BookId = book.Id, BorrowedDay = DateTime.Now }; book.IsAvailable = false; bookRepository.Update(book); return(repository.Add(history)); } return(null); }
public Task Handle(StepChangedEvent notification, CancellationToken cancellationToken) { var journeys = _journeyRepository.GetJourneysByStepIdsAsync(new List <int> { notification.FromStepId, notification.ToStepId }).Result; var fromJourney = journeys.First(j => j.Steps.Any(s => s.Id == notification.FromStepId)); var toJourney = journeys.First(j => j.Steps.Any(s => s.Id == notification.ToStepId)); var fromStep = fromJourney.Steps.Single(s => s.Id == notification.FromStepId); var toStep = toJourney.Steps.Single(s => s.Id == notification.ToStepId); EventType eventType; string description; if (fromJourney.Id == toJourney.Id) { eventType = EventType.StepChanged; description = $"{eventType.GetDescription()} - From '{fromStep.Title}' to '{toStep.Title}' in journey '{fromJourney.Title}'"; } else { eventType = EventType.JourneyChanged; description = $"{eventType.GetDescription()} - From journey '{fromJourney.Title}' / step '{fromStep.Title}' to journey '{toJourney.Title}' / step '{toStep.Title}'"; } var history = new History(notification.Plant, description, notification.ObjectGuid, ObjectType.Tag, eventType); _historyRepository.Add(history); return(Task.CompletedTask); }
public int Create(History history) { ErrorStatus errorStatus = ErrorStatus.New; switch (history.Action) { case HistoryAction.Opening: errorStatus = ErrorStatus.Opened; break; case HistoryAction.Closing: errorStatus = ErrorStatus.Closed; break; case HistoryAction.Resolving: errorStatus = ErrorStatus.Resolved; break; } _errorRepository.Update(new Error { Id = history.ErrorId, Status = errorStatus }); return(_historyRepository.Add(history)); }
public IActionResult Post(History history) { UserProfile userProfile = GetCurrentUserProfile(); history.UserProfileId = userProfile.Id; _historyRepository.Add(history); return(CreatedAtAction("Get", new { id = history.Id }, history)); }
public Task Handle(IntervalChangedEvent notification, CancellationToken cancellationToken) { var requirementDefinition = _requirementTypeRepository.GetRequirementDefinitionByIdAsync(notification.RequirementDefinitionId); var eventType = EventType.IntervalChanged; var description = $"{eventType.GetDescription()} - From {notification.FromInterval} week(s) to {notification.ToInterval} week(s) in '{requirementDefinition.Result.Title}'"; var history = new History(notification.Plant, description, notification.ObjectGuid, ObjectType.Tag, eventType); _historyRepository.Add(history); return(Task.CompletedTask); }
public int Create(Error error) { var errorId = _errorRepository.Add(error); _historyRepository.Add(new History { Date = error.CreationDate, Action = HistoryAction.Creation, Comment = _historyDefaultComment, UserId = error.UserId, ErrorId = errorId }); return(errorId); }
public async Task InvokeAsync(HttpContext httpContext) { if (_routeTemplateCollection == null) { var routeDefinitionUri = new Uri(_mockerOptions.RouteDefinitionsUri, UriKind.RelativeOrAbsolute); var routeDefinitions = await _configurationRetriever.RetrieveRouteDefinitionsAsync <List <RouteDefinition> >(routeDefinitionUri); var routeTemplateCollection = new RouteTemplateCollection <RouteDefinition>(); foreach (var routeDefinition in routeDefinitions) { routeTemplateCollection.Add(routeDefinition.RouteTemplate, routeDefinition); } _routeTemplateCollection = routeTemplateCollection; } var match = _routeTemplateCollection.Match(httpContext.Request.Path); if (match?.Item.RouteMethods == null || !match.Item.RouteMethods.Contains(httpContext.Request.Method)) { await _next(httpContext); return; } await Task.Delay(match.Item.DelayInMilliseconds, httpContext.RequestAborted); httpContext.Response.StatusCode = match.Item.StatusCode; if (match.Item.Headers != null) { foreach (var header in match.Item.Headers) { httpContext.Response.Headers.TryAdd(header.Key, header.Value); } } var body = Encoding.UTF8.GetBytes(match.Item.Body); await httpContext.Response.Body.WriteAsync(body, httpContext.RequestAborted); _historyRepository.Add(new HistoryItem { RequestPath = httpContext.Request.Path, RequestQuery = httpContext.Request.Query.Select(q => new KeyValuePair <string, string>(q.Key, q.Value)).ToList(), RequestMethod = httpContext.Request.Method, RequestHeaders = httpContext.Request.Headers.Select(h => new KeyValuePair <string, string>(h.Key, h.Value.ToString())).ToList() }); }
public Task Handle(TagRequirementPreservedEvent notification, CancellationToken cancellationToken) { var requirementDefinition = _requirementTypeRepository.GetRequirementDefinitionByIdAsync(notification.RequirementDefinitionId); var eventType = EventType.RequirementPreserved; var description = $"{eventType.GetDescription()} - '{requirementDefinition.Result.Title}'"; var history = new History(notification.Plant, description, notification.ObjectGuid, ObjectType.Tag, eventType) { DueInWeeks = notification.DueInWeeks, PreservationRecordGuid = notification.PreservationRecordGuid }; _historyRepository.Add(history); return(Task.CompletedTask); }
public async Task <IActionResult> Post([FromBody] Message model) { var gifter = ParticipantRepository.Get(model.GifterId); var recipient = ParticipantRepository.Get(model.RecipientId); var result = await EmailService.Send(gifter.Email, gifter.Name, recipient.Name); if (result.Successful) { //select strftime('%Y-%m-%d %H:%M:%S',MatchDate/10000000 - 62135596800,'unixepoch') from History HistoryRepository.Add(new History() { GifterId = model.GifterId, RecipientId = model.RecipientId, MatchDate = DateTime.Now }); return(new OkResult()); } return(new BadRequestObjectResult(result)); }
public async Task RealizeOrder(Guid orderId) { var order = await orderRepository.GetOrder(orderId); if (order.Status != Status.InProgress) { return; } order.ChangeStatus(Status.Realized); await historyRepository.Add(new History( DateTime.Now, 0, //TODO order.User.Login, order.OrderId)); await orderRepository.SaveChanges(); }
public async Task <IActionResult> Search(string phrase) { var name = Request.Form["engine"].ToString(); var search = new Search { Phrase = phrase, Date = DateTime.Now }; _searchRepository.Add(search); if (signInManager.IsSignedIn(User)) { var user = await userManager.FindByNameAsync((User.Identity.Name)); var history = new History { Date = search.Date, SearchId = search.ID, UserId = user.Id }; _historyRepository.Add(history); } //else //{ // var user = await userManager.FindByNameAsync("*****@*****.**"); // var history = new History // { // Date = search.Date, // SearchId = search.ID, // UserId = user.Id // }; // _historyRepository.Add(history); //} var check = ApiTask("https://image-spider-server.herokuapp.com/schedule.json", name, search); return(RedirectToAction("Waiting", search)); }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { try { await Task.Delay(TimeSpan.FromMinutes(Config.HistorySaveDelayInMinutes ?? 1), stoppingToken); } catch (TaskCanceledException) { return; } Data toAdd = DataStorage.CurrentData; if (toAdd == null) { continue; // shouldn't happen because CurrentData should never be null } if (toAdd.DatumZeit <= lastDataAdded?.DatumZeit) { continue; // twice the same data -> skip } try { using (var scope = ScopeFactory.CreateScope()) { IHistoryRepository repos = scope.ServiceProvider.GetRequiredService <IHistoryRepository>(); repos.Add(toAdd); lastDataAdded = toAdd; } } catch (Exception e) { Console.WriteLine($"Couldn't save to DB: {e.Message}"); } } }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { try { await Task.Delay(TimeSpan.FromMinutes(Config.SaveIntervalInMinutes), stoppingToken); } catch (TaskCanceledException) { return; } Data?toAdd = DataStorage.CurrentData; if (toAdd == null) { continue; // this can happen at the start of the application as long as no valid data is received } if (lastDataAdded != null && toAdd.DatumZeit <= lastDataAdded.DatumZeit) { continue; // twice the same data -> skip } try { using IServiceScope scope = ScopeFactory.CreateScope(); IHistoryRepository repos = scope.ServiceProvider.GetRequiredService <IHistoryRepository>(); repos.Add(toAdd); lastDataAdded = toAdd; } catch (Exception e) { Console.WriteLine($"Couldn't save to DB: {e.Message}"); } } }
public History Add(History history) { return(historyRepository.Add(history)); }
public History Create(History history) { return(_historyRepository.Add(history)); }
public void Add(HistoryDbModel model) { historyRepository.Add(model); }
public async Task Add(HistoryDbModel model) { ServiceEventSource.Current.ServiceMessage(_context, "HistoryService - Add"); await Task.Factory.StartNew(() => _repo.Add(model)); }