Exemplo n.º 1
0
        public JsonResult Edit(AboutAdminViewModel adminModel)
        {
            var adminFromDB = context.Administrators.Where(a => a.Id == adminModel.Id).First();

            bool result;

            if (!ModelState.IsValid)
            {
                return(Json(new { success = false, message = "Invalid Inputs." }));
            }

            adminFromDB.Name       = adminModel.Name;
            adminFromDB.Email      = adminModel.Email;
            adminFromDB.Education  = adminModel.Education;
            adminFromDB.Country    = adminModel.Country;
            adminFromDB.Headline   = adminModel.Headline;
            adminFromDB.Birthdate  = adminModel.Birthdate;
            adminFromDB.Bio        = adminModel.Bio;
            adminFromDB.ProfilePic = adminModel.ProfileImgUrl;

            context.Entry(adminFromDB).State = EntityState.Modified;
            result = context.SaveChanges() > 0;

            if (result)
            {
                return(Json(new { success = true }));
            }
            else
            {
                return(Json(new { success = false, message = "OPPS! Something went wrong." }));
            }
        }
Exemplo n.º 2
0
        //profile page
        public ActionResult AboutAdmin()
        {
            AboutAdminViewModel adminModel = new AboutAdminViewModel();

            string adminUserName = (string)Session["AdminUserName"];

            if (!string.IsNullOrEmpty(adminUserName))
            {
                adminModel.Administrator = context.Administrators.Include(a => a.Skills).Where(a => a.UserName.Equals(adminUserName.ToLower())).First();
                adminModel.AdminUserName = adminUserName;
            }
            else
            {
                adminModel.Administrator = context.Administrators.Include(a => a.Skills).Where(a => a.UserName.Equals(DefaultAdmin.defaultAdminUserName.ToLower())).First();
            }

            DateTime dateTime = new DateTime(1900, 1, 1);

            adminModel.Administrator.Birthdate = adminModel.Administrator.Birthdate ?? dateTime;

            adminModel.SkillsTypes = context.Skills.Select(s => s.Type).Distinct().ToList();
            adminModel.Skill       = new Skill();

            adminModel.IsAdmin = Session["IsAdmin"] != null && (bool)Session["IsAdmin"] == true;

            adminModel.Admins       = context.Administrators.Where(a => !a.IsMaster).ToList();
            adminModel.MasterAdmins = context.Administrators.Where(a => a.IsMaster).ToList();

            ViewBag.countries = CountriesList.Countries();

            return(View(adminModel));
        }
Exemplo n.º 3
0
        private async Task <Negotiator> Index()
        {
            var vm = new AboutAdminViewModel();

            var systemSettings = await SettingsService.GetSettingsAsync();

            var type = Type.GetType("Mono.Runtime");

            if (type != null) // mono
            {
                vm.Os = "Mono";
                var displayName = type.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
                if (displayName != null)
                {
                    vm.SystemVersion = displayName.Invoke(null, null).ToString();
                }
            }
            else
            {
                // Windows
                vm.Os            = OperatingSystemHelper.GetOs();
                vm.SystemVersion = Environment.Version.ToString();
            }

            vm.ApplicationVersion = AssemblyHelper.GetFileVersion();
            vm.Branch             = EnumHelper <Branches> .GetDisplayValue(systemSettings.Branch);

            vm.LogLevel = LogManager.Configuration.LoggingRules.FirstOrDefault(x => x.NameMatches("database"))?.Levels?.FirstOrDefault()?.Name ?? "Unknown";

            return(View["About", vm]);
        }
Exemplo n.º 4
0
        private string CreateReportBody(AboutAdminViewModel model, string body)
        {
            var sb = new StringBuilder();

            sb.AppendLine("#### Ombi Version");
            sb.AppendLine($"V {model.ApplicationVersion}");
            sb.AppendLine("#### Update Branch:");
            sb.AppendLine(model.Branch);
            sb.AppendLine("#### Operating System:");
            sb.AppendLine(model.Os);
            sb.AppendLine("#### Log Level:");
            sb.AppendLine(model.LogLevel);
            sb.AppendLine(body);

            return(sb.ToString());

            //            <!--- //!! Please use the Support / bug report template, otherwise we will close the Github issue !!
            //(Pleas submit a feature request over here: http://feathub.com/tidusjar/Ombi) //--->

            //#### Ombi Version:

            //V 1.XX.XX

            //#### Update Branch:

            //Stable/Early Access Preview/development

            //#### Operating System:

            //(Place text here)

            //#### Mono Version (only if your not on windows)

            //(Place text here)

            //#### Applicable Logs (from `/logs/` directory or the Admin page):

            //```

            //(Logs go here. Don't remove the ``` tags for showing your logs correctly. Please make sure you remove any personal information from the logs)

            //```

            //#### Problem Description:

            //(Place text here)

            //#### Reproduction Steps:

            //Please include any steps to reproduce the issue, this the request that is causing the problem etc.
        }
Exemplo n.º 5
0
        private async Task <AboutAdminViewModel> GetModel()
        {
            var vm    = new AboutAdminViewModel();
            var oAuth = Session[SessionKeys.OAuthToken]?.ToString() ?? string.Empty;

            if (!string.IsNullOrEmpty(oAuth))
            {
                vm.OAuthEnabled = true;
            }

            var systemSettings = await SettingsService.GetSettingsAsync();

            var type = Type.GetType("Mono.Runtime");

            if (type != null) // mono
            {
                vm.Os = "Mono";
                var displayName = type.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
                if (displayName != null)
                {
                    vm.SystemVersion = displayName.Invoke(null, null).ToString();
                }
            }
            else
            {
                // Windows
                vm.Os            = OperatingSystemHelper.GetOs();
                vm.SystemVersion = Environment.Version.ToString();
            }

            vm.RunningDir = Environment.CurrentDirectory;
            vm.DbLocation = SqlConfig.CurrentPath;

            vm.ApplicationVersion = AssemblyHelper.GetFileVersion();
            vm.Branch             = EnumHelper <Branches> .GetBranchValue <BranchAttribute>(systemSettings.Branch).DisplayName;

            vm.LogLevel = LogManager.Configuration.LoggingRules.FirstOrDefault(x => x.NameMatches("database"))?.Levels?.FirstOrDefault()?.Name ?? "Unknown";

            return(vm);
        }