Example #1
0
        public ActionResult Details(int?id, int?version)
        {
            if (id == null)
            {
                return(StatusCode(StatusCodes.Status400BadRequest));
            }
            if (version != null && version.HasValue)
            {
                int        departmentID = id.Value;
                Department depsVersion  = _departmentService.Get(d => d.Where(x => x.ItemID == departmentID &&
                                                                              ((x.VersionNumber ==
                                                                                version.Value) ||
                                                                               (version.Value == 0 &&
                                                                                x.VersionNumber == null)))
                                                                 .ToList(), GetEntityMode.VersionAndOther).FirstOrDefault();
                if (depsVersion == null)
                {
                    return(StatusCode(StatusCodes.Status404NotFound));
                }

                depsVersion.EmployeesInDepartment = GetEmployeesInDepartment(departmentID);
                depsVersion.Versions = new List <Department>().AsEnumerable();
                return(View(depsVersion));
            }
            else
            {
                Department department = _departmentService.GetById(id.Value);
                if (department == null)
                {
                    return(StatusCode(StatusCodes.Status404NotFound));
                }
                department.EmployeesInDepartment = GetEmployeesInDepartment(department.ID);

                department.Versions = _departmentService.Get(x => x
                                                             .Where(p => /*p.IsVersion == true &&*/ p.ItemID == department.ID || p.ID == department.ID)
                                                             .OrderByDescending(p => p.VersionNumber).ToList(), GetEntityMode.VersionAndOther);

                int versionsCount = department.Versions.Count();
                for (int i = 0; i < versionsCount; i++)
                {
                    if (i == versionsCount - 1)
                    {
                        continue;
                    }

                    var changes = ChangedRecordsFiller.GetChangedData(department.Versions.ElementAt(i), department.Versions.ElementAt(i + 1));
                    department.Versions.ElementAt(i).ChangedRecords = changes;
                }

                return(View(department));
            }
        }
Example #2
0
        public ActionResult Details(int?id, int?version)
        {
            if (id == null)
            {
                _logger.LogWarning(LoggingEvents.GetItemNotFound, "CostItem({id}) not found", id);
                return(StatusCode(StatusCodes.Status400BadRequest));
            }

            if (version != null && version.HasValue)
            {
                int ID            = id.Value;
                var recordVersion = _costItemService.Get(y => y.Where(x => x.ItemID == ID &&
                                                                      ((x.VersionNumber == version.Value) ||
                                                                       (version.Value == 0 &&
                                                                        x.VersionNumber == null)))
                                                         .ToList(), GetEntityMode.VersionAndOther).FirstOrDefault();
                if (recordVersion == null)
                {
                    return(StatusCode(StatusCodes.Status404NotFound));
                }

                recordVersion.Versions = new List <CostItem>().AsEnumerable();
                return(View(recordVersion));
            }

            var record = _costItemService.Get(x => x.Where(c => c.ID == id.Value).ToList()).FirstOrDefault();

            if (record == null)
            {
                _logger.LogWarning(LoggingEvents.GetItemNotFound, "CostItem not found");
                return(StatusCode(StatusCodes.Status404NotFound));
            }

            record.Versions = _costItemService.Get(x => x.Where(p => p.ItemID == record.ID || p.ID == record.ID).OrderByDescending(p => p.VersionNumber).ToList(), GetEntityMode.VersionAndOther);

            int versionsCount = record.Versions.Count();

            for (int i = 0; i < versionsCount; i++)
            {
                if (i == versionsCount - 1)
                {
                    continue;
                }

                var changes = ChangedRecordsFiller.GetChangedData(record.Versions.ElementAt(i), record.Versions.ElementAt(i + 1));
                record.Versions.ElementAt(i).ChangedRecords = changes;
            }

            return(View(record));
        }
Example #3
0
        public ActionResult Details(int?id, int?version)
        {
            if (id == null)
            {
                return(StatusCode(StatusCodes.Status400BadRequest));
            }

            if (version != null && version.HasValue)
            {
                int ID            = id.Value;
                var recordVersion = _budgetLimitService.Get(i => i.Where(x => x.ItemID == ID &&
                                                                         ((x.VersionNumber == version.Value) ||
                                                                          (version.Value == 0 &&
                                                                           x.VersionNumber == null))).ToList(), GetEntityMode.VersionAndOther).FirstOrDefault();
                if (recordVersion == null)
                {
                    return(StatusCode(StatusCodes.Status404NotFound));
                }

                recordVersion.Versions = new List <BudgetLimit>().AsEnumerable();
                return(View(recordVersion));
            }

            var record = _budgetLimitService.GetById(id.Value);

            if (record == null)
            {
                return(StatusCode(StatusCodes.Status404NotFound));
            }

            record.Versions = _budgetLimitService.Get(x => x
                                                      .Where(p => /*p.IsVersion == true &&*/ p.ItemID == record.ID || p.ID == record.ID)
                                                      .OrderByDescending(p => p.VersionNumber).ToList(), GetEntityMode.VersionAndOther);

            int versionsCount = record.Versions.Count();

            for (int i = 0; i < versionsCount; i++)
            {
                if (i == versionsCount - 1)
                {
                    continue;
                }

                var changes = ChangedRecordsFiller.GetChangedData(record.Versions.ElementAt(i), record.Versions.ElementAt(i + 1));
                record.Versions.ElementAt(i).ChangedRecords = changes;
            }

            return(View(record));
        }
        public IList <ProjectScheduleEntry> GetVersions(int projectScheduleEntryId, bool withChangeInfo)
        {
            List <ProjectScheduleEntry> projectScheduleEntryVersion;

            using (var filterDisabler = new FilterDisabler(DbContext, "IsVersion"))
            {
                projectScheduleEntryVersion = GetQueryable().Where(p => p.ItemID == projectScheduleEntryId || p.ID == projectScheduleEntryId)
                                              .OrderByDescending(p => p.VersionNumber).ToList();
            }
            if (withChangeInfo)
            {
                for (int i = 0; i < projectScheduleEntryVersion.Count - 1; i++)
                {
                    var changes = ChangedRecordsFiller.GetChangedData(projectScheduleEntryVersion[i], projectScheduleEntryVersion[i + 1]);
                    projectScheduleEntryVersion[i].ChangedRecords = changes;
                }
            }
            return(projectScheduleEntryVersion);
        }
        public IList <TSAutoHoursRecord> GetVersions(int tsAutoHoursRecordId, bool withChangeInfo)
        {
            List <TSAutoHoursRecord> tsAutoHoursRecordVersion;

            using (var filterDisabler = new FilterDisabler(DbContext, "IsVersion"))
            {
                tsAutoHoursRecordVersion = GetQueryable().Where(p => p.ItemID == tsAutoHoursRecordId || p.ID == tsAutoHoursRecordId)
                                           .OrderByDescending(p => p.VersionNumber)
                                           .ToList();
            }
            if (withChangeInfo)
            {
                for (int i = 0; i < tsAutoHoursRecordVersion.Count - 1; i++)
                {
                    var changes = ChangedRecordsFiller.GetChangedData(tsAutoHoursRecordVersion[i], tsAutoHoursRecordVersion[i + 1]);
                    tsAutoHoursRecordVersion[i].ChangedRecords = changes;
                }
            }
            return(tsAutoHoursRecordVersion);
        }