Example #1
0
        public async Task <JsonResult> ResetPasswordUser(UtentiView model)
        {
            DbObject obj  = new DbObject();
            var      user = await userManager.FindByIdAsync(model.Id);

            if (user != null)
            {
                string password = UtilsHelper.RandomString(8);
                await userManager.RemovePasswordAsync(model.Id);

                await userManager.AddPasswordAsync(model.Id, password);

                string GetCurrentUrl = Request.Url.GetLeftPart(UriPartial.Authority);

                string destinatario      = model.UserName;
                string emaildestinatario = model.UserName;
                string oggetto           = "Reset account NewAge Finanze";
                string corpo             = "<p>La richiesta per il reset della password è stata effettuata.<br/>" +
                                           "Potrai accedere usando le nuove credenziali:</p>" +
                                           "<p>password: "******"</p>";
                string firma = "<strong>-- NewAge Finanze Team</strong>";

                UtilsHelper.InviaLaMail(destinatario, emaildestinatario, null, oggetto, corpo, firma);
                obj.db_obj_ack = "OK";
            }
            else
            {
                obj.db_obj_ack     = "KO";
                obj.db_obj_message = "Non è stato possibile effettuare il reset della password per l'utente selezionato";
            }
            return(Json(obj, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public JsonResult EditRole(UtentiView model)
        {
            var ruoli = new EditRuoliView()
            {
                Id    = model.Id,
                Email = model.UserName,
                ruoli = getRuoli(model)
            };

            return(Json(ruoli, JsonRequestBehavior.AllowGet));
        }
Example #3
0
        private bool getCheck(string name, UtentiView model)
        {
            bool check = false;

            foreach (var x in userManager.GetRoles(model.Id))
            {
                if (x == name)
                {
                    check = true;
                }
            }
            return(check);
        }
Example #4
0
        private IList <RuoliView> getRuoli(UtentiView model)
        {
            var ruoli = db.Roles
                        .ToList()
                        .Select(x =>
            {
                return(new RuoliView()
                {
                    Name = x.Name,
                    check = getCheck(x.Name, model)
                });
            })
                        .ToList();

            return(ruoli);
        }
Example #5
0
        public async Task <JsonResult> Delete(UtentiView model)
        {
            DbObject obj = new DbObject();

            if (string.IsNullOrEmpty(model.Id))
            {
                obj.db_obj_ack     = "KO";
                obj.db_obj_message = "Non è stato possibie eliminare il record corrente.";
            }

            var user = await userManager.FindByIdAsync(model.Id);

            if (user != null)
            {
                db.Users.Remove(user);
                db.SaveChanges();
                obj.db_obj_ack = "OK";
            }
            return(Json(obj, JsonRequestBehavior.AllowGet));
        }