예제 #1
0
        internal static void DeleteHour(HourCriteria criteria)
        {
            var hour = Hour.FetchHour(criteria);

            if (!Hour.CanDeleteObject(hour))
            {
                throw new SecurityException("Only users with full control can delete and archived hour");
            }

            Csla.DataPortal.Delete <Hour>(criteria);
        }
예제 #2
0
        private void DataPortal_Delete(HourCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager <ApplicationEntities>
                             .GetManager(Database.ApplicationConnection, false))
            {
                var data = ctx.ObjectContext.Hours
                           .Single(row => row.HourId == criteria.HourId);

                ctx.ObjectContext.Hours.DeleteObject(data);

                ctx.ObjectContext.SaveChanges();
            }
        }
예제 #3
0
        private void DataPortal_Fetch(HourCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager <ApplicationEntities>
                             .GetManager(Database.ApplicationConnection, false))
            {
                var data = ctx.ObjectContext.Hours
                           .Include("Project")
                           .Include("Task")
                           .Include("User")
                           .Single(row => row.HourId == criteria.HourId);

                this.Fetch(data);

                this.BusinessRules.CheckRules();
            }
        }
예제 #4
0
        private void DataPortal_Fetch(HourCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                        .GetManager(Database.ApplicationConnection, false))
            {
                var data = ctx.ObjectContext.Hours
                    .Include("Project")
                    .Include("Task")
                    .Include("User")
                    .Single(row => row.HourId == criteria.HourId);

                this.Fetch(data);

                this.BusinessRules.CheckRules();
            }
        }
예제 #5
0
        private void DataPortal_Delete(HourCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                        .GetManager(Database.ApplicationConnection, false))
            {
                var data = ctx.ObjectContext.Hours
                    .Single(row => row.HourId == criteria.HourId);

                ctx.ObjectContext.Hours.DeleteObject(data);

                ctx.ObjectContext.SaveChanges();
            }
        }
예제 #6
0
        public ActionResult Index(int[] projectId, int[] userId, int[] taskId, string date, int? isArchived, string label, string text, string sortBy, string sortOrder)
        {
            var model = new HourIndexModel();

            model.Tab = "Hour";
            model.FindText = text;
            model.FindCategory = "Hour";

            model.Projects = DataHelper.GetProjectList();
            model.ProjectId = projectId ?? new int[0];
            model.ProjectName = DataHelper.ToString(model.Projects, model.ProjectId, "any project");
            model.ProjectDisplayName = DataHelper.Clip(model.ProjectName, 40);

            model.Users = DataHelper.GetUserList();
            model.UserId = userId ?? new int[0];
            model.UserName = DataHelper.ToString(model.Users, model.UserId, "any user");
            model.UserDisplayName = DataHelper.Clip(model.UserName, 20);

            model.Label = label;
            model.Date = date ?? string.Empty;
            model.IsArchived = isArchived ?? 1;

            model.Filters = MyService.FilterFetchInfoList("Hour");

            model.SortBy = sortBy ?? "Date";
            model.SortOrder = sortOrder ?? "DESC";
            model.SortableColumns.Add("Date", "Date");
            model.SortableColumns.Add("ProjectName", "Project");
            model.SortableColumns.Add("UserName", "User");

            model.LabelByCountListModel =
                new LabelByCountListModel
                {
                    Action = "Hour",
                    Label = label,
                    Labels = DataHelper.GetTaskLabelByCountList()
                };

            var criteria = new HourCriteria()
            {
                ProjectId = projectId,
                UserId = userId,
                TaskId = taskId,
                Date = new DateRangeCriteria(model.Date),
                IsArchived = DataHelper.ToBoolean(isArchived, false),
                TaskLabels = string.IsNullOrEmpty(label) ? null : new[] { label },
                Text = text
            };

            var hours = HourService.HourFetchInfoList(criteria)
                .AsQueryable();

            hours = hours.OrderBy(string.Format("{0} {1}", model.SortBy, model.SortOrder));

            model.Hours = hours;

            return this.View(model);
        }
예제 #7
0
 internal static Hour FetchHour(HourCriteria criteria)
 {
     return(Csla.DataPortal.Fetch <Hour>(criteria));
 }
예제 #8
0
 internal static HourInfoList FetchHourInfoList(HourCriteria criteria)
 {
     return Csla.DataPortal.Fetch<HourInfoList>(criteria);
 }
예제 #9
0
        private void DataPortal_Fetch(HourCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager <ApplicationEntities>
                             .GetManager(Database.ApplicationConnection, false))
            {
                this.RaiseListChangedEvents = false;
                this.IsReadOnly             = false;

                IQueryable <Data.Hour> query = ctx.ObjectContext.Hours
                                               .Include("Project")
                                               .Include("Task")
                                               .Include("User");
                ;

                if (criteria.HourId != null)
                {
                    query = query.Where(row => row.HourId == criteria.HourId);
                }

                if (criteria.TaskId != null && criteria.TaskId.Count() != 0)
                {
                    query = query.Where(row => criteria.TaskId.Contains(row.TaskId));
                }

                if (criteria.ProjectId != null && criteria.ProjectId.Count() != 0)
                {
                    query = query.Where(row => criteria.ProjectId.Contains(row.ProjectId));
                }

                if (criteria.UserId != null && criteria.UserId.Count() != 0)
                {
                    query = query.Where(row => criteria.UserId.Contains(row.UserId));
                }

                if (criteria.Date.DateFrom.Date != DateTime.MinValue.Date)
                {
                    query = query.Where(row => row.Date >= criteria.Date.DateFrom);
                }

                if (criteria.Date.DateTo.Date != DateTime.MaxValue.Date)
                {
                    query = query.Where(row => row.Date <= criteria.Date.DateTo);
                }

                if (criteria.Duration != null)
                {
                    query = query.Where(row => row.Duration == criteria.Duration);
                }

                if (criteria.Labels != null)
                {
                    query = query.Where(row => row.Labels == criteria.Labels);
                }

                if (criteria.IsArchived != null)
                {
                    query = query.Where(row => row.IsArchived == criteria.IsArchived);
                }

                if (criteria.Notes != null)
                {
                    query = query.Where(row => row.Notes == criteria.Notes);
                }

                if (criteria.ModifiedBy != null)
                {
                    query = query.Where(row => row.ModifiedBy == criteria.ModifiedBy);
                }

                if (criteria.ModifiedDate.DateFrom.Date != DateTime.MinValue.Date)
                {
                    query = query.Where(row => row.ModifiedDate >= criteria.ModifiedDate.DateFrom);
                }

                if (criteria.ModifiedDate.DateTo.Date != DateTime.MaxValue.Date)
                {
                    query = query.Where(row => row.ModifiedDate <= criteria.ModifiedDate.DateTo);
                }

                if (criteria.CreatedBy != null)
                {
                    query = query.Where(row => row.CreatedBy == criteria.CreatedBy);
                }

                if (criteria.CreatedDate.DateFrom.Date != DateTime.MinValue.Date)
                {
                    query = query.Where(row => row.CreatedDate >= criteria.CreatedDate.DateFrom);
                }

                if (criteria.CreatedDate.DateTo.Date != DateTime.MaxValue.Date)
                {
                    query = query.Where(row => row.CreatedDate <= criteria.CreatedDate.DateTo);
                }

                if (criteria.TaskLabels != null &&
                    criteria.TaskLabels.Count() != 0)
                {
                    query = query.Join(ctx.ObjectContext.TaskLabels
                                       .Where(tl => criteria.TaskLabels.Contains(tl.Name)), h => h.TaskId, tl => tl.TaskId, (h, tl) => h);
                }

                if (criteria.Text != null)
                {
                    query = query.Where(row => row.Project.Name.Contains(criteria.Text) ||
                                        row.Notes.Contains(criteria.Text));
                }

                if (criteria.SortBy != null)
                {
                    query = query.OrderBy(string.Format(
                                              "{0} {1}",
                                              criteria.SortBy,
                                              criteria.SortOrder == ListSortDirection.Ascending ? "ASC" : "DESC"));
                }

                if (criteria.MaximumRecords != null)
                {
                    query = query.Take(criteria.MaximumRecords.Value);
                }

                var data = query.AsEnumerable().Select(HourInfo.FetchHourInfo);

                this.AddRange(data);

                this.IsReadOnly             = true;
                this.RaiseListChangedEvents = true;
            }
        }
예제 #10
0
 internal static HourInfoList FetchHourInfoList(HourCriteria criteria)
 {
     return(Csla.DataPortal.Fetch <HourInfoList>(criteria));
 }
예제 #11
0
        private void DataPortal_Fetch(HourCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                        .GetManager(Database.ApplicationConnection, false))
            {
                this.RaiseListChangedEvents = false;
                this.IsReadOnly = false;

                IQueryable<Data.Hour> query = ctx.ObjectContext.Hours
                    .Include("Project")
                    .Include("Task")
                    .Include("User");
                ;

                if (criteria.HourId != null)
                {
                    query = query.Where(row => row.HourId == criteria.HourId);
                }

                if (criteria.TaskId != null && criteria.TaskId.Count() != 0)
                {
                    query = query.Where(row => criteria.TaskId.Contains(row.TaskId));
                }

                if (criteria.ProjectId != null && criteria.ProjectId.Count() != 0)
                {
                    query = query.Where(row => criteria.ProjectId.Contains(row.ProjectId));
                }

                if (criteria.UserId != null && criteria.UserId.Count() != 0)
                {
                    query = query.Where(row => criteria.UserId.Contains(row.UserId));
                }

                if (criteria.Date.DateFrom.Date != DateTime.MinValue.Date)
                {
                    query = query.Where(row => row.Date >= criteria.Date.DateFrom);
                }

                if (criteria.Date.DateTo.Date != DateTime.MaxValue.Date)
                {
                    query = query.Where(row => row.Date <= criteria.Date.DateTo);
                }

                if (criteria.Duration != null)
                {
                    query = query.Where(row => row.Duration == criteria.Duration);
                }

                if (criteria.Labels != null)
                {
                    query = query.Where(row => row.Labels == criteria.Labels);
                }

                if (criteria.IsArchived != null)
                {
                    query = query.Where(row => row.IsArchived == criteria.IsArchived);
                }

                if (criteria.Notes != null)
                {
                    query = query.Where(row => row.Notes == criteria.Notes);
                }

                if (criteria.ModifiedBy != null)
                {
                    query = query.Where(row => row.ModifiedBy == criteria.ModifiedBy);
                }

                if (criteria.ModifiedDate.DateFrom.Date != DateTime.MinValue.Date)
                {
                    query = query.Where(row => row.ModifiedDate >= criteria.ModifiedDate.DateFrom);
                }

                if (criteria.ModifiedDate.DateTo.Date != DateTime.MaxValue.Date)
                {
                    query = query.Where(row => row.ModifiedDate <= criteria.ModifiedDate.DateTo);
                }

                if (criteria.CreatedBy != null)
                {
                    query = query.Where(row => row.CreatedBy == criteria.CreatedBy);
                }

                if (criteria.CreatedDate.DateFrom.Date != DateTime.MinValue.Date)
                {
                    query = query.Where(row => row.CreatedDate >= criteria.CreatedDate.DateFrom);
                }

                if (criteria.CreatedDate.DateTo.Date != DateTime.MaxValue.Date)
                {
                    query = query.Where(row => row.CreatedDate <= criteria.CreatedDate.DateTo);
                }

                if (criteria.TaskLabels != null
                        && criteria.TaskLabels.Count() != 0)
                {
                    query = query.Join(ctx.ObjectContext.TaskLabels
                        .Where(tl => criteria.TaskLabels.Contains(tl.Name)), h => h.TaskId, tl => tl.TaskId, (h, tl) => h);
                }

                if (criteria.Text != null)
                {
                    query = query.Where(row => row.Project.Name.Contains(criteria.Text)
                        || row.Notes.Contains(criteria.Text));
                }

                if (criteria.SortBy != null)
                {
                    query = query.OrderBy(string.Format(
                        "{0} {1}",
                        criteria.SortBy,
                        criteria.SortOrder == ListSortDirection.Ascending ? "ASC" : "DESC"));
                }

                if (criteria.MaximumRecords != null)
                {
                    query = query.Take(criteria.MaximumRecords.Value);
                }

                var data = query.AsEnumerable().Select(HourInfo.FetchHourInfo);

                this.AddRange(data);

                this.IsReadOnly = true;
                this.RaiseListChangedEvents = true;
            }
        }
예제 #12
0
 public static HourInfoList HourFetchInfoList(HourCriteria criteria)
 {
     return HourInfoList.FetchHourInfoList(criteria);
 }