package seedu.tache.logic.commands;

import java.util.HashSet;
import java.util.Set;

import seedu.tache.commons.exceptions.IllegalValueException;
import seedu.tache.logic.commands.exceptions.CommandException;
import seedu.tache.model.tag.Tag;
import seedu.tache.model.tag.UniqueTagList;
import seedu.tache.model.task.Name;
import seedu.tache.model.task.Task;
import seedu.tache.model.task.UniqueTaskList;

/**
 * Adds a task to the task manager.
 */
public class AddCommand extends Command {

    public static final String COMMAND_WORD = "add";

    public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a task to the task manager. "
            + "Parameters: NAME  [t/TAG]...\n"
            + "Example: " + COMMAND_WORD
            + " Buy milk from NTUC  t/HighPriority";

    public static final String MESSAGE_SUCCESS = "New task added: %1$s";
    public static final String MESSAGE_DUPLICATE_TASK = "This task already exists in the task manager";

    private final Task toAdd;

    /**
     * Creates an AddCommand using raw values.
     *
     * @throws IllegalValueException if any of the raw values are invalid
     */
    public AddCommand(String name, Set<String> tags)
            throws IllegalValueException {
        final Set<Tag> tagSet = new HashSet<>();
        for (String tagName : tags) {
            tagSet.add(new Tag(tagName));
        }
        this.toAdd = new Task(
                new Name(name),
                new UniqueTagList(tagSet)
        );
    }

    @Override
    public CommandResult execute() throws CommandException {
        assert model != null;
        try {
            model.addTask(toAdd);
            return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd));
        } catch (UniqueTaskList.DuplicateTaskException e) {
            throw new CommandException(MESSAGE_DUPLICATE_TASK);
        }

    }
}


@@ -56,16 +56,43 @@
 ashSet;%0A
+import java.util.Optional;%0A
 import j
@@ -308,16 +308,96 @@
 agList;%0A
+import seedu.tache.model.task.Date;%0Aimport seedu.tache.model.task.DetailedTask;%0A
 import s
@@ -456,24 +456,60 @@
 .task.Task;%0A
+import seedu.tache.model.task.Time;%0A
 import seedu
@@ -820,19 +820,57 @@
 AME 
- %5Bt/
+%5B;START DATE & TIME%5D %5B;END DATE & TIME%5D %5B;
 TAG
-%5D
 ...
+%5D
 %5Cn%22%0A
@@ -930,30 +930,61 @@
 + %22 
-Buy milk from NTUC  t/
+Orientation week camp; 25/7/16 0800; 28/7/2016 0900; 
 High
@@ -991,16 +991,24 @@
 Priority
+; Events
 %22;%0A%0A    
@@ -1259,22 +1259,35 @@
 ing raw 
+name and tags 
 value
-s
 .%0A     *
@@ -1721,24 +1721,1090 @@
     );%0A    %7D
+%0A    %0A    /**%0A     * Creates an AddCommand using raw name, start date & time, end date & time, and tags values.%0A     *%0A     * @throws IllegalValueException if any of the raw values are invalid%0A     */%0A    public AddCommand(String name, String startDate, String startTime, Optional%3CString%3E endDate, Optional%3CString%3E endTime, Set%3CString%3E tags)%0A            throws IllegalValueException %7B%0A        final Set%3CTag%3E tagSet = new HashSet%3C%3E();%0A        for (String tagName : tags) %7B%0A            tagSet.add(new Tag(tagName));%0A        %7D%0A        Name _name = new Name(name);%0A        Date _startDate = new Date(startDate);%0A        Time _startTime = new Time(startTime);%0A        Date _endDate = null;%0A        if (endDate.isPresent()) %7B%0A            _endDate = new Date(endDate.get());%0A        %7D%0A        Time _endTime = null;%0A        if (endTime.isPresent()) %7B%0A            _endTime = new Time(endTime.get());%0A        %7D%0A        UniqueTagList _tagList = new UniqueTagList(tagSet);%0A        this.toAdd = new DetailedTask(_name, _startDate, _endDate, _startTime, _endTime, _tagList);%0A    %7D
 %0A%0A    @Overr

Update AddCommand to support start and end dates and times