예제 #1
0
        public async Task <ActionResult> DeleteConfirmed(string id)
        {
            VersionFeature versionFeature = await db.VersionFeatureApps.FindAsync(id);

            db.VersionFeatureApps.Remove(versionFeature);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
예제 #2
0
 public VersionFeatureEditModel(VersionFeature data, bool Load)
 {
     this.AppId          = data.AppId;
     this.FeatureAppName = data.FeatureApp.Name;
     this.Version        = data.Version;
     this.FeatureAppId   = data.FeatureAppId;
     this.Content        = data.FeatureApp.Name + data.Content;
     this.AppName        = data.App.Name;
 }
예제 #3
0
        public async Task <ActionResult> VersionFeatureAppsEdit(VersionFeatureEditModel model)
        {
            using (var db = new TDContext())
            {
                if (!ModelState.IsValid)
                {
                    return(Json(Js.Error(this.GetModelStateError())));
                }
                var FeatureAppId = model.Selected;

                var find = db.FeatureApps.Find(FeatureAppId);
                if (find == null)
                {
                    find = db.FeatureApps.FirstOrDefault(x => x.Name == model.Selected);
                    if (find == null)
                    {
                        find = new FeatureApp
                        {
                            Name = model.Selected
                        };
                        db.FeatureApps.Add(find);
                        var str = await db.SaveDatabase();

                        if (str != null)
                        {
                            return(Json(str.GetError()));
                        }
                    }
                    FeatureAppId = find.Id;
                }
                model.FeatureAppId = FeatureAppId;
                var data = await db.VersionFeatureApps.FindAsync(model.AppId, model.Version, FeatureAppId);

                if (data == null)
                {
                    data = new VersionFeature(model);
                    db.VersionFeatureApps.Add(data);
                    var str = await db.SaveDatabase();

                    if (str != null)
                    {
                        return(Json(str.GetError()));
                    }
                }
                data.Content         = model.Content;
                db.Entry(data).State = EntityState.Modified;
                var result = await db.SaveDatabase();

                if (result.NotNull())
                {
                    result.GetError();
                }
                return(Json(Js.SuccessRedirect(TD.Global.VersionFeatureAppChanged, string.Format("{0}/VersionsEdit?AppId={1}&Version={2}", TD.Properties.Resources.AdminAppEditLink, model.AppId, model.Version))));
            }
        }
예제 #4
0
        public async Task <ActionResult> Edit([Bind(Include = "AppId,Version,FeatureAppId,Content")] VersionFeature versionFeature)
        {
            if (ModelState.IsValid)
            {
                db.Entry(versionFeature).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.FeatureAppId = new SelectList(db.FeatureApps, "Id", "Name", versionFeature.FeatureAppId);
            ViewBag.AppId        = new SelectList(db.Apps, "Id", "Database", versionFeature.AppId);
            return(View(versionFeature));
        }
예제 #5
0
        public void Should_Output_Version_To_Console()
        {
            // Given
            var console  = new FakeConsole();
            var resolver = new FakeVersionResolver("1.2.3", "3.2.1");
            var feature  = new VersionFeature(resolver);

            // When
            feature.Run(console);

            // Then
            Assert.Contains("1.2.3", console.Messages);
        }
        public void Should_Return_Success()
        {
            // Given
            var console  = new FakeConsole();
            var resolver = new FakeVersionResolver("1.2.3", "3.2.1");
            var feature  = new VersionFeature(console, resolver);

            // When
            var result = feature.Run();

            // Then
            Assert.Equal(0, result);
        }
예제 #7
0
        // GET: Admin/VersionFeatures/Details/5
        public async Task <ActionResult> Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            VersionFeature versionFeature = await db.VersionFeatureApps.FindAsync(id);

            if (versionFeature == null)
            {
                return(HttpNotFound());
            }
            return(View(versionFeature));
        }
예제 #8
0
        public async Task <ActionResult> VersionFeatureApps(string AppId, LicenseType?Version)
        {
            var db = new TDContext();

            if (string.IsNullOrEmpty(AppId) || Version == null)
            {
                return(View());
            }
            App app = db.Apps.Find(AppId);

            if (app == null)
            {
                return(View());
            }
            var appFeatureApps = db.AppFeatures.Where(x => x.AppId == app.Id);
            var lst            = typeof(LicenseType).GetDictionary();

            foreach (var item in appFeatureApps.ToList())
            {
                foreach (var t in lst)
                {
                    var data = db.VersionFeatureApps.Find(item.AppId, (LicenseType)t.Key, item.FeatureAppId);
                    if (data == null)
                    {
                        data = new VersionFeature
                        {
                            AppId        = item.AppId,
                            Version      = (LicenseType)t.Key,
                            FeatureAppId = item.FeatureAppId,
                            Content      = item.Content
                        };
                        db.VersionFeatureApps.Add(data);
                        var str = await db.SaveDatabase();
                    }
                }
            }
            var partnerApps = db.VersionFeatureApps.Include(X => X.App).Include(x => x.FeatureApp).Where(x => x.AppId == AppId && x.Version == Version).OrderBy(x => x.FeatureApp.Name);

            var model = new List <VersionFeatureEditModel>();

            ViewBag.AppId   = app.Id;
            ViewBag.Version = Version;
            foreach (var item in partnerApps)
            {
                model.Add(new VersionFeatureEditModel(item));
            }
            return(PartialView(model));
        }
예제 #9
0
        // GET: Admin/VersionFeatures/Edit/5
        public async Task <ActionResult> Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            VersionFeature versionFeature = await db.VersionFeatureApps.FindAsync(id);

            if (versionFeature == null)
            {
                return(HttpNotFound());
            }
            ViewBag.FeatureAppId = new SelectList(db.FeatureApps, "Id", "Name", versionFeature.FeatureAppId);
            ViewBag.AppId        = new SelectList(db.Apps, "Id", "Database", versionFeature.AppId);
            return(View(versionFeature));
        }