// GET: Tasks/Details/5 public ActionResult Details(int id) { var item = unitOfWork.TasksRepository.GetByID(id); var vm = TaskMapper.MapItemToViewModel(item); return(View(item)); }
// GET: Tasks public ActionResult Index() { var items = unitOfWork.TasksRepository.Get(); var vmItems = TaskMapper.MapItemToViewModel(items); return(View(vmItems)); }
public ActionResult Create(TaskViewModel model) { try { if (ModelState.IsValid) { if (model.StartDate > model.EndDate) { ModelState.AddModelError("StartDate", "Start date cannot be later than end date of the task"); return(View(model)); } var task = TaskMapper.MapViewModelToItem(model); task.created = DateTime.Today; unitOfWork.TasksRepository.Insert(task); unitOfWork.Save(); return(RedirectToAction("Index")); } } catch (DataException dex) { ModelState.AddModelError("", dex.Message); } return(View(model)); }
public async Task <IActionResult> Update([FromRoute] int id, [FromBody] UpdateTask updateTask) { if (id != updateTask.Id) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var entity = await this.taskService.Get(id); if (entity == null) { return(NotFound()); } await this.taskService.Update(TaskMapper.Map(new Model.Task(), updateTask)); return(NoContent()); } catch (Exception ex) { this.logger.LogError(ex.Message); return(StatusCode((int)HttpStatusCode.InternalServerError, ex.Message)); } }
public static void Update(TaskDto dto) { using (var db = new MainDBModelContainer()) { var newData = TaskMapper.DtoToEntity(dto, db); var oldData = db.TaskSet.Find(dto.Id); if (oldData != null) { oldData.Slug = newData.Slug; oldData.Name = newData.Name; oldData.Description = newData.Description; oldData.CreatedOn = newData.CreatedOn; oldData.Estimate = newData.Estimate; oldData.EndDate = newData.EndDate; oldData.Project = newData.Project; oldData.Milestone = newData.Milestone; oldData.TaskStatus = newData.TaskStatus; oldData.TaskPriority = newData.TaskPriority; db.SaveChanges(); } else { throw new ElementNotFoundException(); } } }
public static ProfileDTO ConvertToDto(Profile profile) { return(new ProfileDTO( id: profile.Id, firstName: profile.FirstName, secondName: profile.SecondName, tasks: TaskMapper.ConvertToListDto(profile.Tasks)?.ToList())); }
public static Profile ConvertFromDto(ProfileDTO profileDto) { return(new Profile( id: profileDto.Id, firstName: profileDto.FirstName, secondName: profileDto.SecondName, tasks: TaskMapper.ConvertFromListDto(profileDto.Tasks)?.ToList())); }
void MainFormLoad(object sender, EventArgs e) { _mapper = new TaskMapper(tasksListView); _mapper.CheckExist(); FielGroupCombo(); FielImportantComboBox(); RestoreTaskFormPosition(); }
public ActionResult Update(int id) { ViewData["updated"] = false; var note = _noteService.Get(id); var model = TaskMapper.Map(note); return(PartialView("Diary/Task/UpdateForm", model)); }
public void ShowDescriptionPanel(TaskMapper _taskToEdit) { taskToEdit = _taskToEdit; descriptionPanel.SetActive(true); taskName.text = taskToEdit.taskName.text; taskDescription.text = taskToEdit.description; idTaskForInfo = taskToEdit.id; }
public async Task <ActionResult <TaskDto> > PostTask(CreateTaskDto createTaskDto) { var taskEntity = TaskMapper.mapFromCreateTask(createTaskDto); _context.Tasks.Add(taskEntity); await _context.SaveChangesAsync(); return(Ok(TaskMapper.mapToDto(taskEntity))); }
public ActionResult CreateTask([FromBody] TaskModel task) { _logger.LogInformation("Creating a new task"); task.LastUpdate = DateTime.UtcNow; var taskData = TaskMapper.SerializeTask(task); var newTask = _taskService.CreateTask(taskData); return(Ok(newTask)); }
public static void Create(TaskDto dto) { using (var db = new MainDBModelContainer()) { var entity = TaskMapper.DtoToEntity(dto, db); db.TaskSet.Add(entity); db.SaveChanges(); } }
public async Task <ActionResult <Dtos.Task> > Create([FromBody] Dtos.Task dto) { var entity = new Entities.Task(); TaskMapper.UpdateEntity(dto, entity); await _repository.SaveAsync(entity); dto = TaskMapper.ToDto(entity); return(CreatedAtAction(nameof(Get), new { id = dto.Id }, dto)); }
public async Task <ActionResult <Dtos.Task> > Get(Guid id) { var entity = await _repository.GetAsync(id); if (entity == null) { return(NotFound()); } return(TaskMapper.ToDto(entity)); }
public TaskManagement.Api.Models.Task Save(TaskManagement.Api.Models.Task task) { var tas = TaskMapper.CreateTask(task); context.tbl_task.Add(tas); context.SaveChanges(); // return the insert element with the right id return(TaskMapper.CreateTask(tas)); }
public async Task <ActionResult <TaskDto> > GetTask(long taskId) { var task = await _context.Tasks.FirstOrDefaultAsync(t => t.Id == taskId); if (task == null) { return(NotFound()); } return(Ok(TaskMapper.mapToDto(task))); }
public static TaskDto Read(int id) { using (var db = new MainDBModelContainer()) { var data = db.TaskSet.Find(id); if (data != null) { return(TaskMapper.EntityToDto(data)); } throw new ElementNotFoundException(); } }
public async Task <IActionResult> OnPostAddTaskAsync() { var mapper = new TaskMapper(FormTask); var taskModel = mapper.Map(); var contest = await _context.Contests.FindAsync(ContestId); contest.Tasks.Add(taskModel); await _context.SaveChangesAsync(); return(RedirectToPage(ContestId)); }
private void WritePrescription(RasterGridPrescription prescription) { var writer = TaskWriter.RootWriter; if (!IsValidPrescription(prescription)) { return; } var prescriptionId = prescription.Id.FindIsoId() ?? GenerateId(); writer.WriteStartElement(XmlPrefix); writer.WriteAttributeString("A", prescriptionId); writer.WriteAttributeString("B", prescription.Description); WriteFieldMeta(writer, prescription.FieldId); // Task status - planned writer.WriteAttributeString("G", "1"); var defaultTreatmentZone = WriteTreatmentZones(writer, prescription); _gridWriter.Write(writer, prescription, defaultTreatmentZone); var matchingLoggedData = null as LoggedData; if (TaskWriter.DataModel.Documents != null && TaskWriter.DataModel.Documents.LoggedData != null) { matchingLoggedData = TaskWriter.DataModel.Documents.LoggedData.Where(ld => ld.OperationData != null).SingleOrDefault(x => x.OperationData.FirstOrDefault(y => y.PrescriptionId == prescription.Id.ReferenceId) != null); } if (matchingLoggedData != null) { var taskMapper = new TaskMapper(); var isoInt = Convert.ToInt32(prescriptionId.Remove(0, 3)) - 1; var mappedTsk = taskMapper.Map(new List <LoggedData> { matchingLoggedData }, TaskWriter.DataModel.Catalog, TaskWriter.BaseFolder, isoInt, TaskWriter).First(); foreach (var item in mappedTsk.Items) { item.WriteXML(TaskWriter.RootWriter); } } else { TaskWriter.Ids.Add(prescriptionId, prescription.Id); } writer.WriteEndElement(); }
public async Task <IResponseWrapper> AddTask(int idProfile, TaskEntity task) { try { var response = await localDataSource.AddTask(idProfile, TaskMapper.ConvertToDto(task)); return(new Success <bool>(response)); } catch (Exception e) { return(new Error(e.Message)); } }
public async Task <IResponseWrapper> GetTaskById(int idTask) { try { var response = await localDataSource.GetTaskById(idTask); return(new Success <TaskEntity>(TaskMapper.ConvertFromDto(response))); } catch (Exception e) { return(new Error(e.Message)); } }
public IEnumerable <TaskItem> GetAll() { NpgsqlCommand command = new NpgsqlCommand("select id, title, " + "is_done, list_id from tasks", conn); using (NpgsqlDataReader dr = command.ExecuteReader()) { while (dr.Read()) { yield return(TaskMapper.map(dr)); } } }
public ActionResult UpdateTask([FromBody] TaskModel task) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } task.LastUpdate = DateTime.UtcNow; var taskData = TaskMapper.SerializeTask(task); var newTask = _taskService.UpdateTask(taskData); return(Ok(newTask)); }
public IEnumerable <TaskVm> DomainToViewList(List <Task> tasks) { var vTasks = new List <TaskVm>(); if (tasks != null && tasks.Count > 0) { foreach (var task in tasks) { vTasks.Add(TaskMapper.Mapper().Map <TaskVm>(task)); } } return(vTasks); }
public ActionResult Create([FromBody] TaskModel task) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _logger.LogInformation("Creating a new task"); task.CreatedOn = DateTime.UtcNow; task.UpdatedOn = DateTime.UtcNow; var taskData = TaskMapper.SerializeTask(task); var newTask = _taskService.Create(taskData); return(Ok(newTask)); }
public async Task <IResponseWrapper> GetProfileTasks(int id) { try { var response = await localDataSource.GetProfileTasks(id); return(new Success <List <TaskEntity> >(TaskMapper.ConvertFromListDto(response).ToList())); } catch (Exception e) { Debug.WriteLine("[ProfileRepository.GetProfileTasks()] Error: " + e.Message); return(new Error(e.Message)); } }
public List <Task> ViewToDomainList(List <TaskVm> tasks) { var vTasks = new List <Task>(); if (tasks != null && tasks.Count > 0) { foreach (var task in tasks) { vTasks.Add(TaskMapper.Mapper().Map <Task>(task)); } } return(vTasks); }
public IEnumerable <TaskItem> GetByListId(long listId) { NpgsqlCommand command = new NpgsqlCommand("select id, title, " + "is_done, list_id from tasks where list_id = @list_id", conn); command.Parameters.AddWithValue("list_id", NpgsqlDbType.Bigint, listId); using (NpgsqlDataReader dr = command.ExecuteReader()) { while (dr.Read()) { yield return(TaskMapper.map(dr)); } } }
public async Task <ActionResult> Update(Guid id, [FromBody] Dtos.Task dto) { var entity = await _repository.GetAsync(id); if (entity == null) { return(NotFound()); } TaskMapper.UpdateEntity(dto, entity); await _repository.SaveAsync(entity); dto = TaskMapper.ToDto(entity); return(Ok()); }
private void WritePrescription(RasterGridPrescription prescription) { var writer = TaskWriter.RootWriter; if (!IsValidPrescription(prescription)) return; var prescriptionId = prescription.Id.FindIsoId() ?? GenerateId(); writer.WriteStartElement(XmlPrefix); writer.WriteAttributeString("A", prescriptionId); writer.WriteAttributeString("B", prescription.Description); WriteFieldMeta(writer, prescription.FieldId); // Task status - planned writer.WriteAttributeString("G", "1"); var defaultTreatmentZone = WriteTreatmentZones(writer, prescription); _gridWriter.Write(writer, prescription, defaultTreatmentZone); var matchingLoggedData = null as LoggedData; if (TaskWriter.DataModel.Documents != null && TaskWriter.DataModel.Documents.LoggedData != null) matchingLoggedData = TaskWriter.DataModel.Documents.LoggedData.Where(ld => ld.OperationData != null).SingleOrDefault(x => x.OperationData.FirstOrDefault(y => y.PrescriptionId == prescription.Id.ReferenceId) != null); if (matchingLoggedData != null) { var taskMapper = new TaskMapper(); var isoInt = Convert.ToInt32(prescriptionId.Remove(0, 3))-1; var mappedTsk = taskMapper.Map(new List<LoggedData> { matchingLoggedData }, TaskWriter.DataModel.Catalog, TaskWriter.BaseFolder, isoInt, TaskWriter).First(); foreach (var item in mappedTsk.Items) { item.WriteXML(TaskWriter.RootWriter); } } else { TaskWriter.Ids.Add(prescriptionId, prescription.Id); } writer.WriteEndElement(); }
public void Setup() { _loggedData = new LoggedData(); _loggedDatas = new List<LoggedData>{ _loggedData }; _catalog = new Catalog(); _datacardPath = ""; _taskDocumentWriter = new TaskDocumentWriter(); _timeMapperMock = new Mock<ITimeMapper>(); _tlgMapperMock = new Mock<ITlgMapper>(); _taskMapper = new TaskMapper(_timeMapperMock.Object, _tlgMapperMock.Object); }