public ActionResult CreatePersonalTask(PlannedTaskToCreate plannedTask) { var person = _repository.GetPersonByName(plannedTask.Person); if (person is null) { return(NotFound()); } var state = _repository.GetStateByName(plannedTask.State); if (state is null) { return(NotFound()); } var newTask = new PlannedTask() { Description = plannedTask.Description, DueDate = plannedTask.DueDate, PersonId = person.Id, StateId = state.Id }; _repository.CreatePersonalTask(newTask); _repository.SaveChanges(); return(Ok()); }
public void DeleteTask(PlannedTask plannedTask) { if (plannedTask is null) { throw new ArgumentException(nameof(plannedTask)); } _context.PlannedTask.Remove(plannedTask); }
public void CreatePersonalTask(PlannedTask plannedTask) { if (plannedTask is null) { throw new ArgumentException(nameof(plannedTask)); } _context.PlannedTask.Add(plannedTask); }
async public Task CreateTask(string title, string description, DateTime deadline, TaskPriority priority) { var task = new PlannedTask { Title = title, Deadline = deadline, Description = description, Priority = priority, State = TaskState.Active, UserId = _userService.CurrentUser().Id }; await _taskRepository.AddAsync(task); }
public async static void Initialize(SicherheitCoreContext context) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); var users = new List <User>(); if (!context.Users.Any()) { for (int i = 1; i <= 5; i++) { User user = new User { EmailAddress = $"user{i}@testowy.pl", Password = "******", Name = $"Testowy user {i}" }; users.Add(user); } } var r = new Random(); var tasks = new List <PlannedTask>(); if (!context.Tasks.Any()) { for (int i = 1; i <= 15; i++) { var rand = r.Next(0, 4); PlannedTask task = new PlannedTask { Title = $"Task {i}", Priority = TaskPriority.Medium, Deadline = new DateTime(2018, 03, i), State = TaskState.Active, UserId = users.ElementAt(rand).Id }; tasks.Add(task); } } await context.Users.AddRangeAsync(users); await context.Tasks.AddRangeAsync(tasks); await context.SaveChangesAsync(); }
public void UpdateTask(PlannedTaskUpdate plannedTaskUpdate, PlannedTask plannedTask) { int stateId; try { stateId = _context.State.FirstOrDefault(p => p.Name == plannedTaskUpdate.State).Id; } catch (ArgumentNullException) { stateId = plannedTask.State.Id; } plannedTask.Description = plannedTaskUpdate.Description; plannedTask.DueDate = plannedTaskUpdate.DueDate; plannedTask.StateId = stateId; }
public async Task CreateAsync(CreatePlannedTaskInputModel input, string userId) { var plannedTask = new PlannedTask { Title = input.Title, Date = input.Date, StartTime = input.StartTime, EndTime = input.EndTime, Description = input.Description, CategoryId = input.CategoryId, CreatedByUserId = userId, }; await this.plannedTasksRepository.AddAsync(plannedTask); await this.plannedTasksRepository.SaveChangesAsync(); }
public static async Task SaveToDb(IEnumerable <TaskInfoViewModel> models) { using (TaskManagerContext db = new TaskManagerContext()) { foreach (var model in models) { PlannedTask task = new PlannedTask() { Title = model.Title, Description = model.Description, CreationDate = model.CreationDate, UpdateDate = model.UpdateDate, EstimatedCompletionDate = model.EstimatedCompletionDate, EstimatedDifficulty = model.EstimatedDifficulty }; var tag = await db.Tags.Include(t => t.PlannedTasks) .SingleOrDefaultAsync(t => model.Tag == t.Name); if (tag == null) { tag = new Tag() { Name = model.Tag }; } task.Tag = tag; var user = await db.Users.SingleOrDefaultAsync(u => u.Login == model.ExecutorLogin); if (user == null) { user = new User() { Login = model.ExecutorLogin, FullName = model.ExecutorFullName }; } task.Executor = user; db.PlannedTasks.Add(task); await db.SaveChangesAsync(); } } }
private static void AddNote(PlannedTask note) { note.Id = Interlocked.Increment(ref _noteCounter); Notes.Add(note); }