public void Create_Void_ReturnId() { _task.Id = _taskRepository.Create(_task); var result = _taskRepository.Get(_task.Id); AreEqualTasks(result, _task); }
public static bool CreateTask(Task task, IEnumerable <Comment> comments) { bool successful = true; try { var taskRepo = new TaskRepository(); var CreatedTask = taskRepo.Create(new Data.Entity.Task() { Title = task.Title, Description = task.Description, Creator = task.Creator, Contractor = task.Contractor, CreatedDate = System.DateTime.Now }); var commentsRepo = new CommentRepository(); foreach (var comment in comments) { commentsRepo.Create(new Data.Entity.Comment { Creator = comment.Creator, Description = comment.Description, Task = CreatedTask.Id }); } } catch (System.Exception ex) { successful = false; } return(successful); }
/// <summary> /// Creates a new Task from the parameter /// </summary> /// <param name="task">Task object with all the properties that will be set on the database</param> public void Create(Common.Task task) { if (task != null) { repository.Create(task); } }
public IHttpActionResult CreateTask([FromBody] CreateTaskCommand command) { if (command == null) { return(BadRequest(DefaultMessages.InvalidBody)); } ValidationError error = new CreateTaskCommandValidator().Validate(command); if (error.IsInvalid) { return(BadRequest(error.Error)); } ProjectsRepository projectsRepository = new ProjectsRepository(Connection, User); Project project = projectsRepository.Find(command.ProjectId); if (project == null) { return(BadRequest("Projeto não encontrado.")); } if (command.RequirementId > 0) { RequirementsRepository requirementsRepository = new RequirementsRepository(Connection); Requirement requirement = requirementsRepository.Find(command.ProjectId, command.RequirementId); if (requirement == null) { return(BadRequest("Requisito não encontrado neste projeto.")); } } TaskRepository taskRepository = new TaskRepository(Connection); return(Ok(taskRepository.Create(command))); }
public TaskEntityModel Task(CreateTaskModel model) { using (var repo = new TaskRepository(_taskDataContext)) { var task = model.Map(); // commit new task to db return(repo.Create(task)); } }
// POST api/<controller> public IHttpActionResult Post([FromBody] Taskk model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } repo.Create(model); return(Ok()); }
public async Task <TaskModel> AddTask(TaskModel task) { var taskRow = new TaskTable() { Id = task.Id, Name = task.Name, Status = task.Status }; await _taskRepository.Create(taskRow); return(task); }
private void CreateTaskWithRepository(IOrganizationService service, string subject) { var taskRepository = new TaskRepository(); taskRepository.Initialize(GetServiceFactoryMockedObject(service), Guid.NewGuid()); taskRepository.Create(new Task { Subject = subject, RegardingObjectId = new EntityReference(Lead.EntityLogicalName, Guid.NewGuid()), OwnerId = new EntityReference(Team.EntityLogicalName, Guid.NewGuid()) }); taskRepository.SaveChanges(); }
public async Task <IHttpActionResult> PostTask(Task task) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { _repo.Create(task); return(CreatedAtRoute("DefaultApi", new { id = task.Id }, task)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public HttpResponseMessage Post(TaskDto dto) { try { if (dto != null) { TaskRepository.Create(dto); return(Request.CreateResponse(HttpStatusCode.OK)); } return(Request.CreateResponse(HttpStatusCode.BadRequest)); } catch (Exception) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Generic error happened.")); } }
static void Main(string[] args) { User user = new User("Marllon Ramos", "*****@*****.**"); UserRepository repository = new UserRepository(); repository.Create(user); Task task = new Task(user, "Nadar"); TaskRepository taskRepository = new TaskRepository(); taskRepository.Create(task); Console.WriteLine("Tarefa cadastrado com sucesso!"); Console.ReadKey(); }
public async Task Create_Inserts_NewTask_With_NoParentTask() { // Arrange var repository = new TaskRepository(dbContext); var parentTaskRepository = new ParentTaskRepository(dbContext); // Act var result = await repository.Create(new Model.Task { Id = 5, Name = "Task 5", Priority = 1, StartDate = new DateTime() }); var actualTasks = await repository.GetAll(); var actualParentTasks = await parentTaskRepository.GetAll(); // Assert Assert.Equal(5, actualTasks.Count()); Assert.Equal(2, actualParentTasks.Count()); }
public State SaveTask(Task task) { HostRepository hostRepo = new HostRepository(); TaskRepository taskRepo = new TaskRepository(); var host = hostRepo.Get(task.HostId); if (host == null) { return new State { IsError = true, Message = "There is no any host with this id!" } } ; if (host.IsBusy) { return new State { IsError = true, Message = "This host is already busy!" } } ; taskRepo.Create(new TaskEntity { HostId = task.HostId, TaskId = task.TaskId, //Array = task.Data.Array, Height = task.Data.Height, Width = task.Data.Width, StepsCount = task.StepsCount }); taskRepo.Save(); host.IsBusy = !(host.IsBusy); hostRepo.Update(host); hostRepo.Save(); return(new State { IsError = false, Message = "Task was saved succesfully!" }); } } }
public void AddTest() { // Arrange var mockDbSet = new Mock <DbSet <TaskItem> >(); var mockContext = new Mock <ApplicationDbContext>(); mockContext.Setup(item => item.Tasks).Returns(mockDbSet.Object); var repository = new TaskRepository(mockContext.Object); // Act var exp = new TaskItem { Id = "4", Description = "ssss" }; repository.Create(exp); // Assert mockDbSet.Verify(m => m.Add(It.IsAny <TaskItem>()), Times.Once()); }
public async Task Create_Does_Not_Inserts_ParentTask_If_Aleardy_Exists() { // Arrange var repository = new TaskRepository(dbContext); var parentTaskRepository = new ParentTaskRepository(dbContext); // Act var result = await repository.Create(new Model.Task { Id = 7, Name = "Task 7", Priority = 1, StartDate = new DateTime(), ParentTask = new Model.ParentTask { Id = 1, Name = "Parent Task 3" } }); var actualTasks = await repository.GetAll(); var actualParentTasks = await parentTaskRepository.GetAll(); // Assert Assert.Equal(5, actualTasks.Count()); Assert.Equal(2, actualParentTasks.Count()); }
}//получаем список всех задач public bool AddTask(int Id, string name, int date_end, string FIO, int admin) { task t = new task(); TaskRepository _t = new TaskRepository(); t.taskID = Id; t.name = name; t.date_end = date_end; t.date_start = DateTime.Today.Day; t.state = "Ready to begin"; _t.Create(t); _t.Save(); if (CreatChat(Id, name) && CreateCommand(Id, Id, admin) && UpdateManager(FIO, Id)) { return(true); } else { _t.Delete(Id); _t.Save(); return(false); } }//добавляем задачу
public void GetByIdTest() { // Arrange var list = GetTestList().AsQueryable(); var mockSet = new Mock <DbSet <TaskItem> >(); mockSet.As <IQueryable <TaskItem> >().Setup(m => m.Provider).Returns(list.Provider); mockSet.As <IQueryable <TaskItem> >().Setup(m => m.Expression).Returns(list.Expression); mockSet.As <IQueryable <TaskItem> >().Setup(m => m.ElementType).Returns(list.ElementType); mockSet.As <IQueryable <TaskItem> >().Setup(m => m.GetEnumerator()).Returns(list.GetEnumerator()); var mockContext = new Mock <ApplicationDbContext>(); mockContext.Setup(item => item.Tasks).Returns(mockSet.Object); var repository = new TaskRepository(mockContext.Object); repository.Create(list.First()); // Act var actual = repository.GetAllWhere(i => i.Id == list.First().Id); //// Assert Assert.Equal(list.First().Id, actual.First().Id); }
// POST: api/ProjTask public void Post(ProjTask p) { TaskRepository.Create(p); }
public void SetUp() { _transactionScope = new TransactionScope(); _commentRepository = new CommentRepository(); _personRepository = new PersonRepository(); _taskRepository = new TaskRepository(); first_person = new PersonItem() { LastName = "Никонов", FirstName = "Денис", Birthday = DateTime.Now.Date, FatherName = "Олегович" }; second_person = new PersonItem() { LastName = "Кажин", FirstName = "Филипп", Birthday = DateTime.Now.AddMonths(-3).Date, FatherName = "Александрович" }; first_task = new TaskItem() { Author = "1", Deadline = DateTime.Now.AddDays(7).Date, Created = DateTime.Now.Date, Performer = "1", Header = "Тестирование демонстрационной задачи", IsOpen = true, IsPerform = false, Mem = "Описание", Number = 1, Priority = 0, Prefix = TaskPrefix.Refactoring }; second_task = new TaskItem() { Author = "2", Deadline = DateTime.Now.AddDays(8).Date, Created = DateTime.Now.Date, Performer = "2", Header = "Тестирование демонстрационной задачи 2", IsOpen = false, IsPerform = true, Mem = "Описание2", Number = 2, Priority = 5, Prefix = TaskPrefix.Demo }; _comment = new CommentItem() { AddDate = DateTime.Now.Date, PersonId = _personRepository.Create(first_person), Text = "Задача номер 1", TaskId = _taskRepository.Create(first_task) }; _commentNew = new CommentItem() { AddDate = DateTime.Now.AddYears(-1).Date, PersonId = _personRepository.Create(second_person), Text = "Задача номер 2", TaskId = _taskRepository.Create(second_task) }; }
public TaskService() { _repo = TaskRepository.Create(); }
public void TaskRepositoryTest_When_Create_ThenThrow_NotImplementedException() { var taskRepo = new TaskRepository(); Assert.ThrowsAsync <NotImplementedException>(async() => await taskRepo.Create(new Structure.Task())); }