예제 #1
0
        public static bool CanSaveObject(Hour hour)
        {
            if (Csla.ApplicationContext.User.IsInRole(Role.FullControl.ToString())
                || (Csla.ApplicationContext.User.IsInRole(Role.Contribute.ToString())
                    && hour.UserId == BusinessPrincipal.GetCurrentIdentity().UserId
                    && !hour.IsArchived))
            {
                return true;
            }

            return false;
        }
예제 #2
0
        public static bool HourDelete(Hour hour)
        {
            Hour.DeleteHour(
                new HourCriteria
                    {
                        HourId = hour.HourId
                    });

            FeedService.FeedAdd("Deleted", hour);

            return true;
        }
예제 #3
0
        public static Feed FeedAdd(string action, Hour hour)
        {
            var feed = FeedService.FeedNew();

            feed.Type = "Hour";
            feed.Data = string.Format(
                "Action={0}|HourId={1}|Date={2:d}|TaskId={3}|ProjectId={4}|ProjectName={5}|Text={6}",
                action,
                hour.HourId,
                hour.Date,
                hour.TaskId,
                hour.ProjectId,
                hour.ProjectName,
                hour.Notes);

            feed = FeedService.FeedSave(feed);

            return(feed);
        }
예제 #4
0
        internal static void FeedAdd(string action, Hour hour)
        {
            var feed = FeedRepository.FeedNew(action, SourceType.Hour, hour.HourId);

            if (action == FeedAction.Edited)
            {
                feed.Description = hour.Auditor.Audit(hour);
            }
            else
            {
                feed.Description = hour.Notes;
            }

            feed.Sources.Add(SourceType.Project, hour.ProjectId);
            feed.Sources.Add(SourceType.Story, hour.StoryId);
            feed.Sources.Add(SourceType.User, hour.UserId);

            feed.Save();
        }
예제 #5
0
        public static Hour HourSave(Hour hour)
        {
            if (!hour.IsValid)
            {
                return(hour);
            }

            Hour result;

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

            StoryRepository.StoryUpdateDuration(hour.StoryId);

            return(result);
        }
예제 #6
0
        public static Hour HourNew()
        {
            var hour = Hour.NewHour();

            return(hour);
        }
예제 #7
0
        public HourFormModel Map(Hour hour, HourFormModel model, bool ignoreBrokenRules)
        {
            Csla.Data.DataMapper.Map(hour, model, true);

            model.Tab = "Hour";
            model.FindText = string.Empty;
            model.FindCategory = "Hour";
            model.Users = DataHelper.GetUserList();
            model.Projects = DataHelper.GetProjectList();
            model.IsNew = hour.IsNew;
            model.IsValid = hour.IsValid;

            if (!ignoreBrokenRules)
            {
                foreach (var brokenRule in hour.BrokenRulesCollection)
                {
                    this.ModelState.AddModelError(string.Empty, brokenRule.Description);
                }
            }

            return model;
        }
예제 #8
0
        public static Hour HourUpdate(Hour hour)
        {
            hour = hour.Save();

            FeedService.FeedAdd("Updated", hour);

            return hour;
        }
예제 #9
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;
        }
예제 #10
0
        public static Hour HourInsert(Hour hour)
        {
            hour = hour.Save();

            FeedService.FeedAdd("Created", hour);

            return hour;
        }