Beispiel #1
0
        public static bool CanSaveObject(Task task)
        {
            if (Csla.ApplicationContext.User.IsInRole(Role.FullControl.ToString())
                || (Csla.ApplicationContext.User.IsInRole(Role.Contribute.ToString())
                    && !task.IsArchived))
            {
                return true;
            }

            return false;
        }
Beispiel #2
0
        private void MapToObject(TaskFormModel model, Task task)
        {
            Csla.Data.DataMapper.Map(
                model, task, true, "EstimatedCompletedDate", "CompletedDate", "AssignedDate", "StartDate", "Labels");

            if (model.Labels == null)
            {
                return;
            }

            switch (SettingHelper.LabelMode)
            {
                case ConfigurationMode.Simple:
                    task.Labels = model.Labels;
                    break;
                case ConfigurationMode.Advanced:
                    var labels = model.Labels.Split(' ');

                    foreach (var label in labels.Where(label => !task.TaskLabels.Contains(label)))
                    {
                        task.TaskLabels.Add(label);
                    }

                    var taskLabelsToRemove = (from taskLabel
                                                  in task.TaskLabels
                                              where !labels.Contains(taskLabel.Name)
                                              select taskLabel.Name)
                        .ToList();

                    foreach (var taskLabel in taskLabelsToRemove)
                    {
                        task.TaskLabels.Remove(taskLabel);
                    }

                    break;
                default:
                    break;
            }
        }
Beispiel #3
0
        private void MapToModel(Task task, TaskFormModel model, bool ignoreBrokenRules)
        {
            Csla.Data.DataMapper.Map(task, model, true, "Labels");

            model.Tab = "Task";
            model.Statuses = DataHelper.GetStatusList();
            model.Categories = DataHelper.GetCategoryList();
            model.Projects = DataHelper.GetProjectList();
            model.Sprints = DataHelper.GetSprintList(task.ProjectId);
            model.Users = DataHelper.GetUserList();

            if (!task.IsNew)
            {
                model.Hours = HourService.HourFetchInfoList(task)
                        .OrderBy(row => row.Date)
                        .AsQueryable();

                model.Invoices = InvoiceService.InvoiceFetchInfoList(task)
                         .OrderByDescending(row => row.Number)
                         .AsQueryable();

                model.NoteListModel =
                    new NoteListModel
                    {
                        Source = task,
                        Notes = NoteService.NoteFetchInfoList(task).AsQueryable()
                    };

                model.LabelListModel =
                    new LabelListModel
                    {
                        Action = "Task",
                        Labels = task.TaskLabels.Select(row => row.Name)
                    };

                model.AttachmentListModel =
                    new AttachmentListModel
                    {
                        Source = task,
                        Attachments = AttachmentService.AttachmentFetchInfoList(task).AsQueryable()
                    };
            }

            switch (SettingHelper.LabelMode)
            {
                case ConfigurationMode.Simple:
                    model.Labels = task.Labels;
                    break;
                case ConfigurationMode.Advanced:
                    model.Labels = task.TaskLabels.ToString();
                    break;
                default:
                    break;
            }

            model.IsNew = task.IsNew;
            model.IsValid = task.IsValid;

            if (ignoreBrokenRules)
            {
                return;
            }

            foreach (var brokenRule in task.BrokenRulesCollection)
            {
                this.ModelState.AddModelError(string.Empty, brokenRule.Description);
            }
        }
Beispiel #4
0
        public static Hour HourSave(Hour hour, Task task)
        {
            if (!hour.IsValid)
            {
                return hour;
            }

            Hour result;

            if (hour.IsNew)
            {
                result = HourService.HourInsert(hour);
            }
            else
            {
                result = HourService.HourUpdate(hour);
            }

            return result;
        }