public ActionResult ChangeClientAppSetting(string AppId, string PartnerId) { if (string.IsNullOrEmpty(AppId) || string.IsNullOrEmpty(PartnerId)) { return(View()); } var app = db.ClientApps.Find(PartnerId, AppId); if (app == null) { return(View()); } var model = new ClientAppEditModel { AppId = AppId, ClientName = app.Client.Name, AppName = app.App.Name, ClientId = PartnerId, Start = app.Start, Expires = app.Expires, LicenseTypes = typeof(LicenseType).GetSelectList(), LicenseType = ((int)app.LicenseType).ToString() }; return(View(model)); }
public async Task <ActionResult> RegisterClientUsingApp(ClientAppEditModel model) { if (!ModelState.IsValid) { return(Json(this.GetModelStateError().GetError())); } var client = await new PartnerDB(db).FindOrAdd(model.ClientId); if (client == null) { return(Json("Vui lòng chọn khách hàng".GetError())); } var data = await db.ClientApps.FindAsync(client.Id, model.AppId); if (data != null) { return(Json("Khách hàng đã sử dụng ứng dụng".GetError())); } data = new ClientApp(client.Id, model.AppId); data.LastModify = DateTime.Now; data.Start = model.Start; if (model.Expires != null) { data.Expires = model.Expires.Value; } data.LicenseType = model.LicenseType.ToEnum <LicenseType>(); db.ClientApps.Add(data); var str = await db.SaveDatabase(); if (str != null) { return(Json(str.GetError())); } return(Json(Js.SuccessRedirect(TD.Global.PartnerAppAdded, TD.Properties.Resources.AdminAppEditLink + model.AppId))); }
public async Task <ActionResult> ChangeClientAppSetting(ClientAppEditModel model) { var data = await db.ClientApps.FindAsync(model.ClientId, model.AppId); if (data == null) { return(Json(TD.Global.PartnerAppNotFound.GetError())); } data.LastModify = DateTime.Now; data.Start = model.Start; if (model.Expires != null) { data.Expires = model.Expires.Value; } if (model.LicenseType != null) { data.LicenseType = model.LicenseType.ToEnum <LicenseType>(); } db.Entry(data).State = EntityState.Modified; var str = await db.SaveDatabase(); if (str != null) { return(Json(str.GetError())); } return(Json(Js.SuccessRedirect(TD.Global.PartnerAppChanged, TD.Properties.Resources.AdminAppEditLink + model.AppId))); }
public async Task <ActionResult> Create(ClientAppEditModel model) { if (!ModelState.IsValid) { return(Json(this.GetModelStateError().GetError())); } var client = await new PartnerDB(db).FindOrAdd(model.ClientId); if (client == null) { return(Json("Vui lòng chọn khách hàng".GetError())); } var data = await db.ClientApps.FindAsync(client.Id, model.AppId); if (data != null) { return(Json("Khách hàng đã sử dụng ứng dụng".GetError())); } data = new ClientApp(client.Id, model.AppId); data.LastModify = DateTime.Now; data.Start = model.Start; if (model.Expires != null) { data.Expires = model.Expires.Value; } data.LicenseType = model.LicenseType.ToEnum <LicenseType>(); db.ClientApps.Add(data); var str = await db.SaveMessageAsync(); if (str != null) { return(Json(str.GetError())); } return(Json(Js.SuccessRedirect(LanguageDB.ClientAppAdded, "/admin/products/edit/" + model.AppId))); }
public async Task <ActionResult> Edit(ClientAppEditModel model) { var data = await db.ClientApps.FindAsync(model.ClientId, model.AppId); if (data == null) { return(Json(LanguageDB.NotFound.GetError())); } data.LastModify = DateTime.Now; data.Start = model.Start; if (model.Expires != null) { data.Expires = model.Expires.Value; } if (model.LicenseType != null) { data.LicenseType = model.LicenseType.ToEnum <LicenseType>(); } db.Entry(data).State = EntityState.Modified; var str = await db.SaveMessageAsync(); if (str != null) { return(Json(str.GetError())); } return(Json(Js.SuccessRedirect(LanguageDB.ClientAppChanged, "/admin/products/edit/" + model.AppId))); }
public ActionResult RegisterClientUsingApp(string id) //App Id { if (string.IsNullOrEmpty(id)) { return(View()); } var app = db.Apps.Find(id); if (app == null) { return(View()); } var model = new ClientAppEditModel { AppId = id, AppName = app.Name, Start = DateTime.Now, Partners = new PartnerDB(db).GetSelectList(), LicenseTypes = typeof(LicenseType).GetSelectList() }; return(View(model)); }