public async Task <ActionResult> StartUpdate(LogUpdate updateChecklist) { var checklist = await _repo.UpdateExists(updateChecklist); if (checklist != null) { return(BadRequest($"{updateChecklist.Process} {updateChecklist.SiteKml} already exists. Please Try again")); } updateChecklist.StartTime = DateTime.Now; updateChecklist.Status = "In Progress"; _repo.Add(updateChecklist); var steps = await _repo.GetSteps(updateChecklist.Idchecklist, updateChecklist.Version); foreach (var s in steps) { var step = new LogUpdateSteps { Step = s.Step, StepText = s.StepText, Title = s.Title, Idupdate = updateChecklist.Idupdate }; _repo.Add(step); } if (await _repo.SaveAll()) { return(CreatedAtAction("GetUpdate", new { id = updateChecklist.Idupdate }, updateChecklist)); } return(BadRequest("Failed to Create Update")); }
private void LogHistory(LogUpdateSteps step, string status, string action) { var user = WindowsIdentity.GetCurrent().Name; var history = new LogUpdateHistory { Idupdate = step.Idupdate, FileTime = DateTime.Now, FileBy = user.Substring(user.IndexOf(@"\") + 1), Status = status, FileAction = action + step.Step }; _repo.Add(history); }
private void LogHistory(LogUpdateSteps step, string status, string action) { var user = this.httpContextAccessor.HttpContext.User.Identity.Name; user = user.Substring(user.IndexOf(@"\") + 1); var history = new LogUpdateHistory { Idupdate = step.Idupdate, FileTime = DateTime.Now, FileBy = user.Substring(user.IndexOf(@"\") + 1), Status = status, FileAction = action + step.Step }; _repo.Add(history); }
private async Task <int> GetAddressId(string address) { int addressId = await _repo.GetAddressId(address) ?? 0; if (addressId == 0) { var newAddress = new Database.Entities.Address() { Created = DateTime.Now, IsConfirmed = false, Label = address, }; await _repo.Add(newAddress); } return(addressId); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { if (filterContext.HttpContext.Request.HttpMethod != "POST") { return; } if (filterContext.ActionDescriptor.ActionName.StartsWith("Create", StringComparison.InvariantCultureIgnoreCase)) { return; } var update = new Update { MadeBy = Environment.UserName, MadeOnUtc = DateTime.UtcNow }; updateRepository.Add(update); UpdateContext.CurrentUpdateId = update.Id; }
//public IEnumerable<ValidationResult> CanAddUpdate(Update newUpdate) //{ // if (newUpdate.status.GetType().Name != "Double") // yield return new ValidationResult("Status", "Not a valid update"); //} public void CreateUpdate(Update update) { updateRepository.Add(update); SaveUpdate(); }
private void SaveProccessedMessage(int updateId, long externalId) => _updateRepository.Add(new ProcessedUpdate(updateId, externalId));