Пример #1
0
        public JsonResult DeleteParameters(string key)
        {
            bool   success = false;
            string message = "";

            try
            {
                repo.GetPuckMeta().Where(x => x.Name == DBNames.EditorSettings && x.Key == key).ToList().ForEach(x => repo.DeleteMeta(x));
                repo.SaveChanges();
                success = true;
            }
            catch (Exception ex)
            {
                success = false;
                message = ex.Message;
                log.Log(ex);
            }
            return(Json(new { success = success, message = message }));
        }
Пример #2
0
        public async Task <ActionResult> ResetPassword(ResetPassword model)
        {
            if (ModelState.IsValid)
            {
                var meta = repo.GetPuckMeta().Where(x => x.Name == DBNames.PasswordResetToken && x.Key == model.ResetToken).FirstOrDefault();

                if (meta == null)
                {
                    ModelState.AddModelError("", "Password reset request not found.");
                    return(View(model));
                }

                var user = await userManager.FindByEmailAsync(meta.Value);

                if (user == null)
                {
                    ModelState.AddModelError("", "User not found.");
                    return(View(model));
                }

                var token = await userManager.GeneratePasswordResetTokenAsync(user);

                var result = await userManager.ResetPasswordAsync(user, token, model.Password);

                if (!result.Succeeded)
                {
                    string message = string.Join(" ", result.Errors.Select(x => x.Description));
                    ModelState.AddModelError("", message);
                    return(View(model));
                }

                repo.DeleteMeta(meta);
                repo.SaveChanges();

                ViewBag.SuccessMessage = "Password successfully changed.";

                return(View(model));
            }
            return(View(model));
        }
        public JsonResult DeleteParameters(string key)
        {
            bool   success = false;
            string message = "";

            try
            {
                var metas = repo.GetPuckMeta().Where(x => x.Name == DBNames.EditorSettings && x.Key == key).ToList();
                var meta  = metas.FirstOrDefault();
                metas.ForEach(x => repo.DeleteMeta(x));

                //clear cached values
                var cachePrefix = "editor_settings_";
                var cacheKey    = cachePrefix + key;
                cache.Remove(cacheKey);
                cache.Remove("null_" + cacheKey);

                var instruction = new PuckInstruction()
                {
                    Count             = 2,
                    ServerName        = ApiHelper.ServerName(),
                    InstructionDetail = $"{cacheKey},{"null_" + cacheKey}",
                    InstructionKey    = InstructionKeys.RemoveFromCache
                };
                repo.AddPuckInstruction(instruction);

                repo.SaveChanges();
                if (meta != null)
                {
                    var    keyParts     = key.Split(new char[] { ':' });
                    var    typeSettings = ApiHelper.EditorSettingTypes().FirstOrDefault(x => x.FullName == keyParts[0]);
                    object model        = JsonConvert.DeserializeObject(meta.Value, typeSettings);
                    ApiHelper.OnAfterSettingsDelete(this, new puck.core.Events.AfterEditorSettingsDeleteEventArgs
                    {
                        Setting = (I_Puck_Editor_Settings)model
                        , SettingsTypeFullName = keyParts[0]
                        , ModelTypeName        = keyParts[1]
                        , PropertyName         = keyParts[2]
                    });
                }
                success = true;
            }
            catch (Exception ex)
            {
                success = false;
                message = ex.Message;
                log.Log(ex);
            }
            return(Json(new { success = success, message = message }));
        }
Пример #4
0
        //
        // GET: /puck/Task/Delete/5

        public JsonResult Delete(int id)
        {
            bool   success = false;
            string message = "";

            try
            {
                repo.GetPuckMeta().Where(x => x.Name == DBNames.Tasks && x.ID == id).ToList().ForEach(x => repo.DeleteMeta(x));
                repo.SaveChanges();
                StateHelper.UpdateTaskMappings(true);
                success = true;
            }
            catch (Exception ex)
            {
                success = false;
                message = ex.Message;
                log.Log(ex);
            }
            return(Json(new { success = success, message = message }));
        }