Ejemplo n.º 1
0
        public ActionResult Tasks(string RecordId, string MenuId, string FromNotification, string NotificationId)
        {
            CrmRepository   crmDB = RepositoryManager.GetRepository <CrmRepository>();
            TaskRepository  tskDB = RepositoryManager.GetRepository <TaskRepository>();
            GenelRepository gnlDB = RepositoryManager.GetRepository <GenelRepository>();
            Task            model = new Task();

            MenuId         = GlobalHelper.Decrypt(MenuId);
            model.RecordId = RecordId;
            model.MenuId   = MenuId;
            SessionContext.Current.ActiveUser.MenuId = MenuId;

            Guid recordId = Guid.Empty;

            model.activeProjects = crmDB.GetProjectList();
            model.activeUsers    = gnlDB.GetActiveUsers();
            model.taskStatus     = tskDB.GetTaskStatusList();
            model.taskPriority   = tskDB.GetTaskPriorityList();

            if (GlobalHelper.IsGuid(model.RecordId))
            {
                try
                {
                    recordId = Guid.Parse(model.RecordId);
                    model    = tskDB.BindTask(model, recordId);


                    ViewBag.ResultMessage = Resources.GlobalResource.transaction_success;

                    if (FromNotification == "1" && GlobalHelper.IsGuid(NotificationId))
                    {
                        gnlDB.UpdateNotificationShown(Guid.Parse(NotificationId));
                    }
                }
                catch (Exception exp)
                {
                    ViewBag.Success = false;
                    ModelState.AddModelError("Error", exp.Message);
                }
            }
            else
            {
                if (recordId == Guid.Empty)
                {
                    model.task_user_id     = SessionContext.Current.ActiveUser.UserUid.ToString();
                    model.assigned_user_id = SessionContext.Current.ActiveUser.UserUid.ToString();
                }
            }



            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult Tasks(Task model)
        {
            Guid            recordId = Guid.Empty;
            TaskRepository  tskDB    = RepositoryManager.GetRepository <TaskRepository>();
            CrmRepository   crmDB    = RepositoryManager.GetRepository <CrmRepository>();
            GenelRepository gnlDB    = RepositoryManager.GetRepository <GenelRepository>();

            SessionContext.Current.ActiveUser.MenuId = model.MenuId;
            ViewBag.Success = true;

            model.activeProjects = crmDB.GetProjectList();
            model.activeUsers    = gnlDB.GetActiveUsers();
            model.taskStatus     = tskDB.GetTaskStatusList();
            model.taskPriority   = tskDB.GetTaskPriorityList();

            ModelState.Remove("is_active");
            ModelState.Remove("is_task_sent");

            if (model.FromDeleteButton == "1")
            {
                if (GlobalHelper.IsGuid(model.RecordId))
                {
                    tskDB.DeleteTask(model, Guid.Parse(model.RecordId));
                    return(RedirectToAction("ListPage", "General", new { MenuId = Dcm.Source.GlobalHelper.Encrypt(model.MenuId) }));
                }
            }
            else if (model.FromCreateTaskButton == "1")
            {
                if (GlobalHelper.IsGuid(model.RecordId))
                {
                    tskDB.UpdateTaskStatus(model, Guid.Parse(model.RecordId), (int)Enums.TaskStatus.Gonderildi, true);
                    model = tskDB.BindTask(model, Guid.Parse(model.RecordId));

                    ViewBag.ResultMessage = Resources.GlobalResource.transaction_success;
                }
            }
            else if (model.FromAddExplanationButton == "1")
            {
                if (GlobalHelper.IsGuid(model.RecordId))
                {
                    tskDB.UpdateExplanation(model, Guid.Parse(model.RecordId));
                    model = tskDB.BindTask(model, Guid.Parse(model.RecordId));

                    ViewBag.ResultMessage = Resources.GlobalResource.transaction_success;
                }
            }
            else
            {
                if (ModelState.IsValid)
                {
                    if (GlobalHelper.IsGuid(model.RecordId))
                    {
                        recordId = Guid.Parse(model.RecordId);
                        try
                        {
                            if (model.task_user_id != BaseDB.SessionContext.Current.ActiveUser.UserUid.ToString() && model.assigned_user_id == BaseDB.SessionContext.Current.ActiveUser.UserUid.ToString())
                            {
                                tskDB.UpdateTaskStatus(model, Guid.Parse(model.RecordId), Convert.ToInt32(model.task_status_id), model.is_active);
                                model = tskDB.BindTask(model, Guid.Parse(model.RecordId));
                            }
                            else
                            {
                                model = tskDB.UpdateTask(model, recordId);
                                model = tskDB.BindTask(model, Guid.Parse(model.RecordId));
                            }

                            ViewBag.ResultMessage = Resources.GlobalResource.transaction_success;
                        }
                        catch (Exception exp)
                        {
                            ViewBag.Success = false;
                            ModelState.AddModelError("Error", exp.Message);
                        }
                    }
                    else
                    {
                        try
                        {
                            tsk_tasks task = new tsk_tasks();
                            tskDB.AddTask(task, model);
                            model.RecordId = task.task_id.ToString();

                            ViewBag.ResultMessage = Resources.GlobalResource.transaction_success;
                        }
                        catch (Exception exp)
                        {
                            ViewBag.Success = false;
                            ModelState.AddModelError("Error", exp.Message);
                        }
                    }
                }
                else
                {
                    ViewBag.Success = false;
                }
            }

            return(View(model));
        }