Beispiel #1
0
        private static Application CreateFromFilter(IQueryFilter filter, Database database = null)
        {
            Database db  = database ?? Db.For <Application>();
            var      dao = new Application();

            filter.Parameters.Each(p =>
            {
                dao.Property(p.ColumnName, p.Value);
            });
            dao.Save(db);
            return(dao);
        }
Beispiel #2
0
 public ActionResult Update(Bam.Net.ServiceProxy.Secure.Application dao)
 {
     try
     {
         dao.Save();
         return(Json(new { Success = true, Message = "", Dao = dao.ToJsonSafe() }));
     }
     catch (Exception ex)
     {
         return(GetErrorResult(ex));
     }
 }
Beispiel #3
0
        public static ApplicationCreateResult CreateApplication(IHttpContext context, IUserResolver userResolver, string applicationName, Database database = null)
        {
            ApplicationCreateResult result = new ApplicationCreateResult();

            try
            {
                Application app = Application.OneWhere(c => c.Name == applicationName, database);
                if (app != null)
                {
                    result.Status = ApplicationCreateStatus.NameInUse;
                }
                else
                {
                    string createdBy = userResolver.GetUser(context);
                    if (string.IsNullOrEmpty(createdBy))
                    {
                        createdBy = userResolver.GetCurrentUser();
                        if (string.IsNullOrEmpty(createdBy))
                        {
                            throw new UnableToResolveUserException(userResolver);
                        }
                    }

                    app = new Application
                    {
                        Name = applicationName
                    };
                    app.Save(database);
                    AddKey(app, userResolver, context);

                    result.Application = app;
                    result.Status      = ApplicationCreateStatus.Success;
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                result.Status  = ApplicationCreateStatus.Error;
            }

            return(result);
        }