Exemplo n.º 1
0
        public async Task <ActionResult> AppVersionsAdd(AppVersionView model)
        {
            using (var db = new TDContext())
            {
                if (!ModelState.IsValid)
                {
                    return(Json(Js.Error(this.GetModelStateError())));
                }
                var version = model.Selected.ToEnum <LicenseType>();


                var data = await db.AppVersions.FindAsync(model.AppId, version);

                if (data != null)
                {
                    return(Json("Đã tồn tại phiên bản ứng dụng này".GetError()));
                }
                model.Version = version;
                data          = new AppVersion(model);
                db.AppVersions.Add(data);
                var str = await db.SaveDatabase();

                if (str != null)
                {
                    return(Json(str.GetError()));
                }
                return(Json(Js.SuccessRedirect("Đã thêm phiên bản", TD.Properties.Resources.AdminAppsLink + "/AppVersionsEdit?AppId=" + model.AppId + "&Version=" + version)));
            }
        }
Exemplo n.º 2
0
 public AppVersion(AppVersionView data)
 {
     this.AppId    = data.AppId;
     this.Version  = data.Version;
     this.Price    = data.Price;
     this.OldPrice = data.OldPrice;
     this.Discount = data.Discount;
 }
Exemplo n.º 3
0
        public ActionResult AppVersionsEdit(string AppId, LicenseType?Version)
        {
            if (string.IsNullOrEmpty(AppId) || Version == null)
            {
                return(View());
            }
            var app = db.AppVersions.Find(AppId, Version.Value);

            if (app == null)
            {
                return(View());
            }
            var model = new AppVersionView(app)
            {
                Selected    = ((int)Version).ToString(),
                AllVersions = GetAllLicenseType()
            };

            return(View(model));
        }
Exemplo n.º 4
0
        public ActionResult _GetPrice(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(HttpNotFound());
            }
            var appPrices = db.AppVersions.Include(X => X.App).Where(x => x.AppId == id);
            var lst       = new List <AppVersionView>();

            foreach (var item in appPrices)
            {
                var add = new AppVersionView(item, true);

                foreach (var item2 in db.VersionFeatureApps.Where(x => x.AppId == item.AppId && x.Version == item.Version))
                {
                    add.FeatureApps.Add(new VersionFeatureEditModel(item2, true));
                }
                lst.Add(add);
            }
            return(PartialView(lst));
        }
Exemplo n.º 5
0
        public ActionResult AppVersionsAdd(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(View());
            }
            var app = db.Apps.Find(id);

            if (app == null)
            {
                return(View());
            }
            var model = new AppVersionView
            {
                AppId       = app.Id,
                AppName     = app.Name,
                AllVersions = GetAllLicenseType(app, true)
            };

            return(View(model));
        }
Exemplo n.º 6
0
        public async Task <ActionResult> AppVersionsEdit(AppVersionView model)
        {
            using (var db = new TDContext())
            {
                if (!ModelState.IsValid)
                {
                    return(Json(Js.Error(this.GetModelStateError())));
                }
                var version = model.Selected.ToEnum <LicenseType>();



                var data = await db.AppVersions.FindAsync(model.AppId, version);

                if (data == null)
                {
                    model.Version = version;
                    data          = new AppVersion(model);
                    db.AppVersions.Add(data);
                    var str = await db.SaveDatabase();

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

                if (result.NotNull())
                {
                    result.GetError();
                }
                return(Json(Js.SuccessRedirect(TD.Global.AppVersionChanged, TD.Properties.Resources.AdminAppEditLink + model.AppId)));
            }
        }