public ActionResult Get(UserPreference preference) { using (new PerformanceMonitor()) { try { if (null == preference) { return(this.Json(WebResponse.Bind((int)Fault.DataNotSpecified, "Preference not specified"), JsonRequestBehavior.AllowGet)); } else { var user = User.Identity.Data(); var app = Application.Current; preference.User = user; preference.Application = app; var saved = userCore.Get(preference); saved.CanCreateApplication = appCore.PermitApplicationCreation(app, user); return(this.Json(saved, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { logger.Log(ex, EventTypes.Error, (int)Fault.Unknown); return(this.Json(WebResponse.Bind((int)Fault.Unknown, ex.Message), JsonRequestBehavior.AllowGet)); } } }
/// <summary> /// Check if the current user Can Create An Application /// </summary> /// <returns>Can Create An Application</returns> private bool CanCreateAnApplication() { using (new PerformanceMonitor()) { return(appCore.PermitApplicationCreation(Abc.Services.Contracts.Application.Current, User.Identity.Data())); } }
public void PermitApplicationCreationNullUser() { var app = new Application() { Identifier = Guid.NewGuid(), }; var core = new ApplicationCore(); core.PermitApplicationCreation(app, null); }
public void PermitApplicationCreationNullApplication() { var user = new User() { Identifier = Guid.NewGuid(), }; var core = new ApplicationCore(); core.PermitApplicationCreation(null, user); }
public void PermitApplicationCreationEmptyUserIdentifier() { var user = new User() { Identifier = Guid.Empty, }; var app = new Application() { Identifier = Guid.NewGuid(), }; var core = new ApplicationCore(); core.PermitApplicationCreation(app, user); }
public ActionResult CanCreateAnApplication() { using (new PerformanceMonitor()) { try { var user = User.Identity.Data(); return(this.Json(appCore.PermitApplicationCreation(Application.Current, user), JsonRequestBehavior.AllowGet)); } catch (Exception ex) { logger.Log(ex, EventTypes.Error, (int)Fault.Unknown); return(this.Json(WebResponse.Bind((int)Fault.Unknown, ex.Message), JsonRequestBehavior.AllowGet)); } } }
public void PermitApplicationCreation() { var application = Application.Default; var userData = new UserData(StringHelper.ValidString(), StringHelper.ValidString(), StringHelper.ValidString()); var tbl = new AzureTable <UserData>(CloudStorageAccount.DevelopmentStorageAccount); tbl.AddEntity(userData); var user = new User() { Identifier = userData.Id, }; var row = new UserPreferenceRow(application.Identifier, user.Identifier); var table = new AzureTable <UserPreferenceRow>(CloudStorageAccount.DevelopmentStorageAccount); table.AddEntity(row); var appCore = new ApplicationCore(); appCore.PermitApplicationCreation(application, user); }