コード例 #1
0
 public ResponseModel Delete(int id)
 {
     ResponseModel response;
     try
     {
         bool deleted = projectService.Delete(id);
         response = deleted  ? new ResponseModel(id) : new ResponseModel(null, false, "Couldn't delete");
     }
     catch (Exception exception)
     {
         response = new ResponseModel(null, false, "Error occurred", exception);
     }
     return response;
 }
コード例 #2
0
 public ResponseModel Get()
 {
    ResponseModel response;
    try
    {
        List<ProjectViewModel> projects = projectService.GetAll();
        response = new ResponseModel(projects);
    }
    catch (Exception exception)
    {
       response = new ResponseModel(null,false,"Error occurred",exception);
    } 
     return response;
 }
コード例 #3
0
 public ResponseModel Post(Project project)
 {
     ResponseModel response;
     try
     {
         int id = projectService.Save(project);
         response = id>0 ? new ResponseModel(id) : new ResponseModel(null,false,"Couldn't save");
     }
     catch (Exception exception)
     {
         response = new ResponseModel(null, false, "Error occurred", exception);
     }
     return response;
 }
コード例 #4
0
 public ResponseModel Get(int projectId)
 {
     ResponseModel response;
     try
     {
         List<TaskViewModel> tasks = projectId == 0 ? _taskService.GetAll():_taskService.GetAllByProject(projectId);
         response = new ResponseModel(tasks);
     }
     catch (Exception exception)
     {
         response = new ResponseModel(null, false, "Error occurred", exception);
     }
     return response;
 }
コード例 #5
0
 public ResponseModel Post(Task task)
 {
     TaskService service = new TaskService();
     ResponseModel responseModel;
     try
     {
         bool completed = service.MarkCompleter(task);
         responseModel = new ResponseModel(isSuccess: completed);
     }
     catch (Exception exception)
     {
         responseModel = new ResponseModel(isSuccess: false,exception:exception,message:"Couldn't mark complete the task");
     }
     return responseModel;
 }
コード例 #6
0
 public ResponseModel Post(Task task)
 {
     ResponseModel response;
     try
     {
         task.Project = null;
         int id = _taskService.Save(task);
         response = id > 0 ? new ResponseModel(id) : new ResponseModel(null, false, "Couldn't save");
     }
     catch (Exception exception)
     {
         response = new ResponseModel(null, false, "Error occurred", exception);
     }
     return response;
 }
コード例 #7
0
        public ResponseModel Get(int projectId, string sortOn="", string sortBy="")
        {
            ResponseModel response;
            try
            {
                List<TaskViewModel> tasks = projectId == 0 ? service.GetAll() : service.GetAllByProject(projectId, sortOn, sortBy);

                response=new ResponseModel(tasks);
            }
            catch (Exception exception)
            {
                response=new ResponseModel(null,false,"Error Occurred",exception);
            }
            return response;
        }
コード例 #8
0
 public ResponseModel GetDetail(int id)
 {
     ResponseModel response;
     try
     {
         if (id > 0)
         {
             Task task = _taskService.GetById(id);
             response = new ResponseModel(task);
         }
         else
         {
             response = new ResponseModel(isSuccess:false,message:"Id can't be zero.");
         }
     }
     catch (Exception exception)
     {
         response = new ResponseModel(null, false, "Error occurred", exception);
     }
     return response;
 }