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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }