예제 #1
0
        public async Task <ActionResult <CreationResult> > CreateVersionInfo(AppVersionData newAppVersion, int id = -1)
        {
            int appId = id == -1 ? (int)newAppVersion.AppID : id;


            AppVersion toAdd = new AppVersion
            {
                AppID         = appId,
                Changelog     = newAppVersion.Changelog,
                VresionName   = newAppVersion.VresionName,
                VresionNumber = newAppVersion.VresionNumber,
                ReleaseDate   = newAppVersion.ReleaseDate,
                ChannelID     = newAppVersion.ChannelID
            };

            _context.AppVersions.Add(toAdd);
            await _context.SaveChangesAsync();

            _context.Entry(toAdd).Reference(x => x.Channel).Load();
            _context.Entry(toAdd).Reference(x => x.App).Load();
            Channel channel = toAdd.Channel;

            if (channel.ChannelName.ToLower() == "release")
            {
                App app = toAdd.App;
                if (app.Published)
                {
                    await _notificationsHub.SendNotification("new version" + newAppVersion.VresionNumber + " of " + app.Name);
                }
            }
            return(new CreationResult {
                txt = "Done", ID = toAdd.ID + ""
            });
        }
예제 #2
0
        public async Task <IActionResult> PutChannelData(int?id, ChannelData channelData)
        {
            Channel toChange = new Channel {
                ChannelName = channelData.ChannelName, ID = (int)id
            };

            if (id != toChange.ID)
            {
                return(BadRequest());
            }

            _context.Entry(toChange).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ChannelDataExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #3
0
        public async Task <IActionResult> PutEnviromentData(int?id, EnviromentData enviromentData)
        {
            Enviroment tochange = new Enviroment {
                ID = (int)id, EnviromentName = enviromentData.EnviromentName
            };

            if (id != tochange.ID)
            {
                return(BadRequest());
            }

            _context.Entry(tochange).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EnviromentDataExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #4
0
        public async Task <ActionResult <CreationResult> > CreateStageInfo(StageData newStage, int id = -1)
        {
            int versionID = id == -1 ? (int)newStage.AppVersionID : id;

            AppVersion appvr = _context.AppVersions.Where(x => x.ID == versionID).SingleOrDefault();

            _context.Entry(appvr).Reference(c => c.App).Load();

            App app = appvr.App;

            String fileSrc  = "";
            float  fileSize = 0.0f;

            if (app.Public)
            {
                fileSrc  = newStage.FSsource;;
                fileSize = 0.0f; //GetFileSize(fileSrc);
            }
            else
            {
                _context.Entry(app).Reference(c => c.Enviroment).Load();

                String iconsSrc = app.FSiconsSources;

                if (app.Enviroment.EnviromentName.ToLower() == "android")
                {
                    fileSrc = _fileHander.acceptableName("Apk", newStage.FSsource);
                    _fileHander.saveFile("Apk", newStage.FSsource, fileSrc);
                    fileSize = _fileHander.FileSize("Apk", fileSrc);
                }
                else if (app.Enviroment.EnviromentName.ToLower() == "ios")
                {
                    String tmpIpaSrc = _fileHander.acceptableName("Ipa", newStage.FSsource);
                    _fileHander.saveFile("Ipa", newStage.FSsource, tmpIpaSrc);
                    fileSrc = _fileHander.GenerateManifest(tmpIpaSrc, iconsSrc, versionID);
                }
            }
            Stage toAdd = new Stage
            {
                AppVersionID = versionID,
                FSsource     = fileSrc,
                Size         = fileSize,
            };

            _context.Stages.Add(toAdd);
            await _context.SaveChangesAsync();

            return(new CreationResult {
                txt = "Done", ID = toAdd.ID + ""
            });
        }
예제 #5
0
        public async Task <ActionResult <CreationResult> > CreateAppInfo(AppData newApp)
        {
            String txt  = "";
            User   user = _userManager.GetUserAsync(HttpContext.User).Result;

            String videoSrc = _fileHandler.acceptableName("Video", newApp.Video);

            _fileHandler.saveFile("Video", newApp.Video, videoSrc);

            String screenShotsSrc = _fileHandler.acceptableName("Image", newApp.ScreenShots);

            _fileHandler.saveFile("Image", newApp.ScreenShots, screenShotsSrc);

            String iconsSrc = _fileHandler.acceptableName("Icon", newApp.FSiconsSources);

            _fileHandler.saveFile("Icon", newApp.FSiconsSources, iconsSrc);

            App toAdd = new App
            {
                Name             = newApp.Name,
                Description      = newApp.Description,
                PackageName      = newApp.PackageName,
                Downloads        = 0,
                WebSite          = newApp.WebSite,
                Published        = (bool)newApp.Published,
                Public           = (bool)newApp.Public,
                EnviromentID     = (int)newApp.EnviromentID,
                UserID           = user.Id,
                FSiconsSources   = iconsSrc,
                ScreenShots      = screenShotsSrc,
                Video            = videoSrc,
                SupportedDevices = newApp.SupportedDevices
            };

            _context.Apps.Add(toAdd);
            await _context.SaveChangesAsync();

            return(new CreationResult {
                txt = "Done", ID = toAdd.ID + ""
            });
        }