Esempio n. 1
0
        public bool insert(TaskVM taskVM)
        {
            var push               = new Task(taskVM);
            var getStatus          = applicationContext.Statuses.Find(taskVM.Status_Id);
            var getProject         = applicationContext.Projects.Find(taskVM.Project_Id);
            var getProjectByMember = applicationContext.ProjectMembers.Find(taskVM.Assigned_By_Member);
            var getProjectToMember = applicationContext.ProjectMembers.Find(taskVM.Assigned_To_Member);

            if (getProjectByMember != null && getProjectToMember != null && getStatus != null && getProject != null)
            {
                push.Status  = getStatus;
                push.Project = getProject;
                applicationContext.Tasks.Add(push);
                var result = applicationContext.SaveChanges();
                if (result > 0)
                {
                    status = true;
                    return(status);
                }
                else
                {
                    return(status);
                }
            }
            else
            {
                return(status);
            }
        }
Esempio n. 2
0
        public IActionResult Upsert(int?id)
        {
            TaskVM taskVM = new TaskVM()
            {
                Task     = new ToDoList.Models.Task(),
                TypeList = _unitOfWork.TaskType.GetAll().Select(i => new SelectListItem()
                {
                    Text  = i.Type,
                    Value = i.TaskTypeId.ToString()
                }),
                EmployeeList = _unitOfWork.Employee.GetAll().Select(i => new SelectListItem()
                {
                    Text  = i.Name,
                    Value = i.EmployeeId.ToString()
                })
            };

            if (id == null) //create
            {
                return(View(taskVM));
            }
            taskVM.Task = _unitOfWork.Task.Get(id.GetValueOrDefault()); //edit
            if (taskVM.Task == null)
            {
                return(NotFound());
            }

            return(View(taskVM));
        }
Esempio n. 3
0
        public static Dictionary <string, string> CreateTask(TaskVM task)
        {
            var response = new Dictionary <string, string>();

            if (string.IsNullOrEmpty(task.Taskname))
            {
                response.Add("taskname", "Task name cannot be null");
            }

            if (string.IsNullOrEmpty(task.Description))
            {
                response.Add("description", "Description cannot be null");
            }

            if (task.EffortId < 1)
            {
                response.Add("effort", "You need to select effort");
            }

            if (task.PriorityId < 1)
            {
                response.Add("priority", "You need to select priority");
            }

            if (task.TeamId == null)
            {
                response.Add("teamid", "Team id unknown");
            }

            return(response);
        }
        /// <summary>
        /// Create new task
        /// </summary>
        /// <param name="model"></param>
        /// <returns>CreateTaskCommandResult</returns>
        public async Task CreateTask(TaskVM model)
        {
            try
            {
                var updatedModel = model.ToCreateTaskCommand();
                if (!updatedModel.AssignedToId.HasValue)
                {
                    updatedModel.AssignedToId = null;
                }
                var result = await Create(updatedModel);

                Tasks = (await GetAllTasks()).Payload.ToList();
                if (result != null)
                {
                    TaskCreatedSuccess.Invoke(this, null);
                }
                else
                {
                    TaskCreatedFailed.Invoke(this, null);
                }
            }
            catch (Exception ex)
            {
                TaskCreatedFailed.Invoke(this, null);
            }
        }
Esempio n. 5
0
        public bool CreateTask(TaskVM model)
        {
            bool success = false;

            using (var db = new ManagementToolEntities())
            {
                var resp = new TaskRepository(db);

                var task = new DBModels.Task
                {
                    Title         = model.Title,
                    Description   = model.Description,
                    DueDate       = DateTime.Parse(model.DueDate),
                    Status        = model.Status.ToString(),
                    ProjectId     = model.ProjectId,
                    ExpendedHours = model.TaskHours,
                    Category      = model.Category,
                    AssignedTo    = model.Developer
                };

                resp.Insert(task);
                success = db.SaveChanges() > 0;
            }

            return(success);
        }
        public TaskVM Save(TaskVM taskVM)
        {
            try
            {
                var task = new Task
                {
                    Id = taskVM.Id,
                    Name = taskVM.Name,
                    StartedBy = taskVM.StartedBy,
                    StartedOn = taskVM.StartedOn,
                    EndedOn = taskVM.EndedOn
                };
                _unitOfWork.Tasks.Save(task);
                _unitOfWork.SaveChanges();

                return new TaskVM
                {
                    Id = task.Id,
                    Name = task.Name,
                    StartedBy = task.StartedBy.Value,
                    StartedOn = task.StartedOn,
                    EndedOn = task.EndedOn
                };
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
                return null;
            }
        }
        public JsonResult Add(TaskVM task)
        {
            if (!String.IsNullOrWhiteSpace(task.Description))
            {
                Task t = new Task();
                t.ID          = Guid.NewGuid();
                t.Description = task.Description;
                t.DashboardID = task.DashboardID;
                t.CreatedDate = DateTime.Parse(DateTime.Now.ToShortDateString());
                db.Tasks.Add(t);

                var result = db.SaveChanges();
                if (result > 0)
                {
                    Log.Debug("[TODOAPP]: Task creatad " + t.Description);
                    return(JsonSuccess(t, "Task created!"));
                }
                else
                {
                    Log.Error("[TODOAPP]: Task can't creatad");
                    return(JsonError("Task can't added!"));
                }
            }
            else
            {
                Log.Error("[TODOAPP]: Task description empty error");
                return(JsonError("Task can't added!"));
            }
        }
Esempio n. 8
0
        public IActionResult Create([FromBody] TaskVM Task)
        {
            var task = _mapper.Map <Tasks>(Task);

            _taskRepository.CreateTask(task);
            return(Ok(task));
        }
Esempio n. 9
0
        /// <summary>
        /// 获取用户对应的任务列表
        /// </summary>
        /// <param name="taskGuid"></param>
        public List <TaskVM> GetTaskListByUser(string UserID)
        {
            List <TaskVM> taskList = new List <TaskVM>();
            TaskVM        taskVM   = null;
            List <RtTask> tasks    = AntApi.DB.RtTasks.Where(o => (o.Executor == UserID) || (o.Owner == UserID && string.IsNullOrEmpty(o.Executor))).ToList <RtTask>();

            if (tasks.Count() > 0)
            {
                foreach (RtTask task in tasks)
                {
                    taskVM              = new TaskVM();
                    taskVM.TaskGuid     = task.TaskGuid;
                    taskVM.InstanceGuid = task.InstanceGuid;
                    taskVM.TaskTitle    = task.TaskTitle;
                    if (task.InstanceGuid_FK != null)
                    {
                        taskVM.InstanceTitle = task.InstanceGuid_FK.InstanceTitle;
                        taskVM.StartTime     = task.InstanceGuid_FK.StartTime;
                    }
                    taskVM.CreateTime = task.CreateTime;
                    taskList.Add(taskVM);
                }
                return(taskList.OrderByDescending(o => o.CreateTime.Value).ToList());
            }
            return(null);
        }
Esempio n. 10
0
        public IActionResult CreateTask(TaskVM task)
        {
            if (ModelState.IsValid)
            {
                Models.Task taskdb = new Models.Task();
                taskdb.Completed   = false;
                taskdb.Date        = task.Date;
                taskdb.Description = task.Description;
                taskdb.Finish      = task.Finish;
                taskdb.Priority    = task.Priority;
                taskdb.Start       = task.Start;
                taskdb.Title       = task.Title;
                User user = UserManager.GetUserByUsername(User.Identity.Name);
                taskdb.UserId = user.Id;
                taskdb.User   = user;

                TaskManager.AddTask(taskdb);
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                //TO do error message not valid task
                return(null);
            }
        }
Esempio n. 11
0
        public ActionResult Create(TaskVM poViewModel)
        {
            ViewBag.AC_MENU_ID = valMENU.TSK_TASK_CREATE;
            TaskVM oViewModel = poViewModel;

            oViewModel.RESOWNER_ID = hlpConfig.SessionInfo.getAppResId();
            this.oVAL = new Task_Validation(oViewModel, this.oDS);
            this.oVAL.Validate_Create();

            //Add Error if exists
            for (int i = 0; i < oVAL.aValidationMSG.Count; i++)
            {
                ModelState.AddModelError(this.oVAL.aValidationMSG[i].VAL_ERRID, this.oVAL.aValidationMSG[i].VAL_ERRMSG);
            } //End for (int i = 0; i < this.oVAL.aValidationMSG.Count; i++)

            if (ModelState.IsValid)
            {
                this.oCRUD.Create(oViewModel);
                if (this.oCRUD.isERR)
                {
                    TempData["ERRMSG"] = this.oCRUD.ERRMSG;
                    return(RedirectToAction("ErrorSYS", "Error"));
                } //End if (!this.oCRUD.isERR) {

                TempData["CRUDSavedOrDelete"] = valFLAG.FLAG_TRUE;
                return(RedirectToAction("Details", new { id = this.oCRUD.ID }));
            } //End if (ModelState.IsValid)
            this.prepareLookup();
            return(View(poViewModel));
        }
Esempio n. 12
0
        public ActionResult Edit(TaskVM poViewModel)
        {
            ViewBag.AC_MENU_ID = valMENU.TSK_TASK_EDIT;
            this.oVAL          = new Task_Validation(poViewModel, this.oDS);
            this.oVAL.Validate_Save();

            //Add Error if exists
            for (int i = 0; i < this.oVAL.aValidationMSG.Count; i++)
            {
                ModelState.AddModelError(this.oVAL.aValidationMSG[i].VAL_ERRID, this.oVAL.aValidationMSG[i].VAL_ERRMSG);
            } //End for (int i = 0; i < this.oVAL.aValidationMSG.Count; i++)

            if (ModelState.IsValid)
            {
                this.oCRUD.Update(poViewModel);
                if (this.oCRUD.isERR)
                {
                    TempData["ERRMSG"] = this.oCRUD.ERRMSG;
                    return(RedirectToAction("ErrorSYS", "Error"));
                } //End if (!this.oCRUD.isERR) {

                TempData["CRUDSavedOrDelete"] = valFLAG.FLAG_TRUE;
                return(RedirectToAction("Details", new { id = this.oCRUD.ID }));
            }
            this.prepareLookup();
            return(View(poViewModel));
        }
Esempio n. 13
0
        public void Setup()
        {
            VM = new TaskVM();
            VM.ChangeValidationStateToValid();

            ValidationStateChangedEvent = new PropertyChangedCounter(VM, "Item[]");
        }
Esempio n. 14
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,Title,Description,CreateDate,UpdateDate,DeletedDate,isActive,CustomerId")] TaskVM task)
        {
            if (id != task.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var _task = _mapper.Map <TaskVM, Model.Task>(task);
                    _taskAppService.Update(_task);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TaskExists(task.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            var customers = _mapper.Map <IEnumerable <Model.Task>, IEnumerable <TaskVM> >(_taskAppService.GetAll());

            ViewData["CustomerId"] = new SelectList(customers, "Id", "Name", task.CustomerId);
            return(View(task));
        }
Esempio n. 15
0
        //Init
        private void initConstructor(DBMAINContext poDB)
        {
            //DBContext
            this.db = poDB;
            //VM
            this.oVM = new TaskVM();
            //DS
            this.oDS              = new TaskDS(this.db);
            this.oDSDetail        = new TaskdDS(this.db);
            this.oDSDetail_worker = new Taskd_workerDS(this.db);
            this.oDSEmployee      = new EmployeeDS(this.db);
            this.oDSEmployeeuser  = new EmployeeuserDS(this.db);
            this.oDSMonth         = new MonthDS(this.db);
            this.oDSYear          = new YearDS(this.db);
            this.oDSProgresssts   = new ProgressstsDS(this.db);
            this.oDSValidatests   = new ValidatestsDS(this.db);
            this.oDSProject       = new ProjectDS(this.db);
            //CRUD
            this.oCRUD = new Task_workerCRUD(this.db);

            //BL
            //MAP
            //JSON
            JsSerialize = new JavaScriptSerializer();
        } //End initConstructor
Esempio n. 16
0
        public ActionResult Edit(int?id = null)
        {
            ViewBag.AC_MENU_ID = valMENU.TSK_TASK_EDIT;
            ViewBag.CRUD_type  = hlpFlags_CRUDOption.UPDATE;

            this.oData        = oDS.getData(id);
            this.oData.DETAIL = oDSDetail.getDatalist_byForeignId(this.oData.ID);
            if (this.oData == null)
            {
                return(HttpNotFound());
            }
            //Validate custom rules
            int?nROLE_ID = hlpConfig.SessionInfo.getAppRoleId();

            if (nROLE_ID != valROLE.ROLEID_ADMIN)
            {
                int?nRES_ID = hlpConfig.SessionInfo.getAppResId();
                if (this.oData.RES_ID == nRES_ID)
                {
                    return(RedirectToAction("Error403", "Error"));
                }
            } //end if
            this.prepareLookup();
            this.setJson();
            return(View(this.oData));
        }
Esempio n. 17
0
 public void Run(TaskVM taskVM)
 {
     TaskVM      = taskVM;
     t           = new System.Timers.Timer(1000);
     t.AutoReset = true;
     t.Elapsed  += T_Elapsed;
     t.Start();
 }
Esempio n. 18
0
        public void Run(TaskVM taskVM)
        {
            TaskVM = taskVM;

            timeBeginPeriod(1);
            mHandler = new TimerEventHandler(TimerCallback);
            mTimerId = timeSetEvent(1000, 0, mHandler, IntPtr.Zero, EVENT_TYPE);
        }
Esempio n. 19
0
        public ActionResult TaskDetails(int id)
        {
            var model    = new TaskVM();
            var mediator = new TaskMediator();

            model = mediator.GetTask(id);
            return(View("~/Views/Task/TaskDetail.cshtml", model));
        }
Esempio n. 20
0
        public ActionResult Filter_member(TaskVM poViewModel)
        {
            ViewBag.AC_MENU_ID = valMENU.TSK_TASK_REPORT_MEMBER;
            ViewBag.CRUD_type  = hlpFlags_CRUDOption.VIEW;
            return(RedirectToAction("Taskprint", new { id = poViewModel.RES_ID }));

            return(View(new BaseVM()));
        }
Esempio n. 21
0
        public ActionResult Filter_admin(TaskVM poViewModel)
        {
            ViewBag.AC_MENU_ID = valMENU.TSK_TASK_REPORT_ADMIN;
            ViewBag.CRUD_type  = hlpFlags_CRUDOption.VIEW;
            return(RedirectToAction("Taskprint", new { id = poViewModel.RES_ID }));

            return(View(poViewModel));
        }
        public TodayTodoItems()
        {
            InitializeComponent();
            TaskVM instance = TaskVM.Instance;

            GroupItemTodoVM.Instance.Reload();
            lvTodoItemsToday.ItemsSource = GroupItemTodoVM.Instance.groupedTodoItems;
        }
Esempio n. 23
0
 public Task(TaskVM taskVM)
 {
     this.Description = taskVM.Description;
     this.Start_Date  = taskVM.Start_Date;
     this.Due_Date    = taskVM.Due_Date;
     this.Priority    = taskVM.Priority;
     this.CreateDate  = DateTimeOffset.Now.ToLocalTime();
 }
Esempio n. 24
0
 public void Update(int id, TaskVM taskVM)
 {
     this.Id          = id;
     this.Description = taskVM.Description;
     this.Start_Date  = taskVM.Start_Date;
     this.Due_Date    = taskVM.Due_Date;
     this.Priority    = taskVM.Priority;
     this.UpdateDate  = DateTimeOffset.Now.ToLocalTime();
 }
Esempio n. 25
0
        // show task
        public IActionResult ShowTask(long Id)
        {
            var taskvm = new TaskVM();

            taskvm.ParentId  = adamUnit.TaskRepository.SingleOrDefault(x => x.Id == Id).Id;
            taskvm.Employees = adamUnit.EmployeeRepository.GetAllInclude().ToList();
            taskvm.Projects  = adamUnit.ProjectRepository.GetAll().ToList();

            return(PartialView("_PartialTask", taskvm));
        }
Esempio n. 26
0
        public IActionResult Put([FromBody] TaskVM taskVm)
        {
            //taskVm.UserId = UserId;
            var request = new TaskRequest {
                Task = taskVm
            };
            var response = _service.UpdateTask(request);

            return(response.Success ? Ok(response) : StatusCode(404, response.Errors));
        }
Esempio n. 27
0
 public ActionResult Edit(long id, TaskVM taskVM)
 {
     if (ModelState.IsValid)
     {
         taskService.Update(taskVM.Task);
         return RedirectToAction("Index");
     }
     taskVM.Load(null,taskService);
     return View("EditTask", taskVM);
 }
Esempio n. 28
0
        void StartWorkflow(StepWorkflow workflow, string name, Action <StepWorkflow> shutdown = null)
        {
            //setup task
            workflow.StepChanged += Workflow_StepChanged;
            ActiveStep            = null;
            ActiveTask            = new TaskVM(workflow, name, shutdown);

            //start workflow
            App.Instance.Arm.Behaviors.Add(workflow);
        }
Esempio n. 29
0
 public ActionResult Create(TaskVM taskVM)
 {
     if (ModelState.IsValid)
     {
         taskVM.SetTaskStartDate();
         taskService.Create(taskVM.Task);
         return RedirectToAction("Index");
     }
     taskVM.Load(null,taskService);
     return View("CreateTask", taskVM);
 }
Esempio n. 30
0
 public bool insert(TaskVM taskVM)
 {
     if (string.IsNullOrWhiteSpace(taskVM.Project_Id.ToString()) && string.IsNullOrWhiteSpace(taskVM.Status_Id.ToString()) && string.IsNullOrWhiteSpace(taskVM.Assigned_By_Member.ToString()) && string.IsNullOrWhiteSpace(taskVM.Assigned_To_Member.ToString()))
     {
         return(status);
     }
     else
     {
         return(iTaskRepository.insert(taskVM));
     }
 }
Esempio n. 31
0
 public void Run(TaskVM taskVM)
 {
     TaskVM        = taskVM;
     TaskVM.Status = Shared.Enums.Status.Run;
     t             = new System.Timers.Timer(1000)
     {
         AutoReset = true
     };
     t.Elapsed += T_Elapsed;
     t.Start();
 }
Esempio n. 32
0
        public TaskVM GetTaskInfoById(int id)
        {
            TaskVM dto = new TaskVM();

            tbl_Task objTask = entDB.tbl_Task.Find(id);

            dto.Id       = objTask.Id;
            dto.TaskName = objTask.TaskName;

            return(dto);
        }
Esempio n. 33
0
 // GET: Task/Create
 public ActionResult Create()
 {
     var viewModel = new TaskVM();
     viewModel.Load(null, taskService);
     return View("CreateTask", viewModel);
 }
Esempio n. 34
0
 // GET: Task/Delete/5
 public ActionResult Delete(long id)
 {
     var viewModel = new TaskVM();
     viewModel.Load(id,taskService);
     return View("DeleteTask", viewModel);
 }