Example #1
0
        public Task <bool> CopyEpsMappingAsync(int fromVersionID, int toVersionID, string userName)
        {
            if (epsMapping.Any(s => s.versionID == fromVersionID))
            {
                if (epsMapping.Any(s => s.versionID == toVersionID))
                {
                    var removeList = epsMapping.ToList().Where(s => s.versionID == toVersionID).ToList();
                    foreach (var item in removeList)
                    {
                        epsMapping.Remove(item);
                    }
                    foreach (var item in epsMapping.Where(s => s.versionID == fromVersionID).ToList())
                    {
                        var eps = (EPSMapping)MockUtility.CloneObject(item);
                        eps.versionID = toVersionID;
                        epsMapping.Add(eps);
                    }

                    var table = (PetroTable)MockUtility.CloneObject(petroTable.Where(s => s.VersionID == fromVersionID).FirstOrDefault());
                    table.VersionID = toVersionID;
                    petroTable.Add(table);
                    return(Task.Run(() => true));
                }
                else
                {
                    throw new Exception("To version not exists");
                }
            }
            else
            {
                throw new Exception("From version not exists");
            }
        }
Example #2
0
        public Task <bool> CreateVersionAsync(Wp.CIS.LynkSystems.Model.CommanderVersion commanderVersion)
        {
            if (versionInfo.Any(s => s.VersionDescription == commanderVersion.VersionDescription))
            {
                throw new Exception("Same version already exists");
            }
            if (!ValidateVersionFormat(commanderVersion.VersionDescription))
            {
                throw new Exception("Invalid version format");
            }
            if (commanderVersion.BaseVersionID.HasValue)
            {
                if (!versionInfo.Any(s => Convert.ToInt32(s.VersionID) == commanderVersion.BaseVersionID))
                {
                    throw new Exception("Base version not exists");
                }
            }
            int newVersionId = versionInfo.Max(s => Convert.ToInt32(s.VersionID)) + 1;

            commanderVersion.VersionID = Convert.ToString(newVersionId);
            versionInfo.Add(commanderVersion);
            if (commanderVersion.BaseVersionID.HasValue)
            {
                var mapping = (EPSMapping)MockUtility.CloneObject(epsMapping.Where(s => s.versionID == commanderVersion.BaseVersionID.Value).FirstOrDefault());
                mapping.versionID = newVersionId;
                epsMapping.Add(mapping);

                var table = (PetroTable)MockUtility.CloneObject(petroTable.Where(s => s.VersionID == commanderVersion.BaseVersionID.Value).FirstOrDefault());
                table.VersionID = newVersionId;
                petroTable.Add(table);
            }
            return(Task.Run(() => true));
        }