Ejemplo n.º 1
0
        public IHttpActionResult ApproveUser(int id, AppUser app)
        {
            var user = db.AppUsers.Get(id);

            if (user == null)
            {
                return(BadRequest("User doesn`t exist"));
            }

            user.Approved = app.Approved;

            try
            {
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                return(BadRequest("Somebody already change user"));
            }

            var    userStore   = new UserStore <RAIdentityUser>(new RADBContext());
            var    userManager = new UserManager <RAIdentityUser>(userStore);
            string Email       = userManager.FindByName(user.Username).Email;

            HelperController.sendAccountConfirmationEmail(Email);

            return(Ok());
        }
Ejemplo n.º 2
0
        public IHttpActionResult ApproveService(int id, Service service)
        {
            if (!db.Services.AsNoTracking().Any(x => x.Id == id))
            {
                return(BadRequest("Bad id"));
            }

            db.Services.Get(id).Approved = service.Approved;

            try
            {
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                return(BadRequest("Somebody already changed this service"));
            }
            var     userStore   = new UserStore <RAIdentityUser>(new RADBContext());
            var     userManager = new UserManager <RAIdentityUser>(userStore);
            AppUser userko      = db.AppUsers.Get(db.Services.Get(id).AppUserId);
            string  Email       = userManager.FindByName(userko.Username).Email;

            HelperController.sendServiceConfirmationEmail(Email, db.Services.Get(id).Name);

            return(Ok());
        }