Ejemplo n.º 1
0
        public HttpResponseMessage Post(TaskEntryViewModel model)
        {
            var command = _mappingEngine.Map <CreateTaskCommand>(model);

            var response = _commandBus.Send(command);

            return(response.Success ? SuccessResponseMessage() : ErrorResponseMessage(response));
        }
 public void EditTaskEntry(TaskEntryViewModel taskEntryViewModel)
 {
     taskEntryViewModel.UpdatedAt = DateTime.Now;
     using (IDbConnection db =
                new SqlConnection(ConfigurationManager.ConnectionStrings["SampleDb"].ConnectionString))
     {
         db.Execute(
             "UPDATE task_entries SET task_id = @TaskId, duration = @Duration, note = @Note, start_time = @StartTime, updated_at = @UpdatedAt WHERE id = @Id", taskEntryViewModel);
     }
 }
 public void InsertTaskEntry(TaskEntryViewModel taskEntryViewModel)
 {
     taskEntryViewModel.UpdatedAt = DateTime.Now;
     using (IDbConnection db =
                new SqlConnection(ConfigurationManager.ConnectionStrings["SampleDb"].ConnectionString))
     {
         db.Execute(
             "INSERT INTO task_entries (task_id, duration, note, start_time, updated_at) VALUES (@TaskId, @Duration, @Note, @StartTime, @UpdatedAt)", taskEntryViewModel);
     }
 }
        public ActionResult SaveTaskEntry(TaskEntryViewModel taskEntry)
        {
            var taskEntryRepository = new TaskEntryRepository();

            if (taskEntry.Id == 0)
            {
                taskEntryRepository.InsertTaskEntry(taskEntry);
            }
            else
            {
                taskEntryRepository.EditTaskEntry(taskEntry);
            }
            return(RedirectToAction("Index", new { TaskId = taskEntry.TaskId }));
        }