Exemplo n.º 1
0
        public ActionResult Detail(int?id, Usuarios model, HttpPostedFileBase userimage, List <int> colrols)
        {
            CustomMemberShipProvider objCustom  = new CustomMemberShipProvider(SessionCustom, HttpContext);
            RolUserRepository        objuserrol = new RolUserRepository(SessionCustom);

            model.UserCustom.LanguageId = 2;

            if (model.UserCustom.Password != null)
            {
                model.UserCustom.Password = Utils.EncriptSHA1(model.UserCustom.Password);
            }

            if (userimage != null && userimage.ContentLength > 0)
            {
                string userImage = Utils.UploadFile(
                    userimage,
                    HttpContext.Server.MapPath("~"),
                    @"resources\imagesuser\",
                    null);

                ImageResize objresize = new ImageResize(HttpContext.Server.MapPath("~"));
                objresize.Width  = 100;
                objresize.Height = 95;
                objresize.Prefix = "_";
                objresize.Resize(@"resources\imagesuser\" + userImage, ImageResize.TypeResize.BackgroundProportional);

                System.IO.File.Delete(System.IO.Path.Combine(HttpContext.Server.MapPath("~"), @"resources\imagesuser\" + userImage));
                model.UserCustom.Image = "_" + userImage;
            }

            if (id != null)
            {
                objuserrol.Entity.UserId = model.UserCustom.UserId = id;
                objCustom.ChangeData(model.UserCustom);
                objuserrol.Delete();
            }
            else
            {
                model.UserCustom.Joindate = DateTime.Now;
                objuserrol.Entity.UserId  = objCustom.CreateUser(model.UserCustom);
            }

            if (colrols != null)
            {
                foreach (int item in colrols)
                {
                    objuserrol.Entity.RolId = item;
                    objuserrol.Insert();
                }
            }

            return(this.RedirectToAction("Index", "Usuarios"));
        }
Exemplo n.º 2
0
        /// <summary>
        /// obtains the user detail
        /// </summary>
        /// <param name="id">identifier of user</param>
        /// <returns>returns the result to action</returns>
        public ActionResult Detail(int?id)
        {
            UserRepository    objUser    = new UserRepository(SessionCustom);
            RolRepository     objrol     = new RolRepository(SessionCustom);
            RolUserRepository objuserrol = new RolUserRepository(SessionCustom);

            if (id != null)
            {
                objuserrol.Entity.UserId = objUser.Entity.UserId = id;
                objUser.Load();
                ViewBag.id = id;
            }

            return(this.View(new Usuarios()
            {
                UserPrincipal = CustomUser,
                Module = this.Module,
                ColModul = CustomMemberShipProvider.GetModuls(CustomUser.UserId, SessionCustom, HttpContext),
                CollRols = objrol.GetAll(),
                UserCustom = objUser.Entity,
                CollUserrol = id != null ? objuserrol.GetAllReadOnly() : null,
                CurrentLanguage = CurrentLanguage
            }));
        }
Exemplo n.º 3
0
        /// <summary>
        /// validates whether a user exists
        /// </summary>
        /// <param name="context">HTTP context</param>
        /// <param name="twitterId">twitter id</param>
        /// <returns>returns a <c>AuthencReturn</c></returns>
        public AuthencReturn ValidateUserTwitter(HttpContextBase context, string twitterId)
        {
            try
            {
                this.Userrepository.Entity.TwitterId = twitterId;
                this.Userrepository.Load();

                if (this.Userrepository.Entity.UserId != null && this.Userrepository.Entity.Active == true)
                {
                    LanguageRepository languagerepo = new LanguageRepository(this.session);
                    languagerepo.Entity.LanguageId = this.Userrepository.Entity.LanguageId;
                    languagerepo.LoadByKey();

                    if (context.Session["lang"] == null)
                    {
                        context.Session.Add("lang", languagerepo.Entity);
                    }
                    else
                    {
                        context.Session["lang"] = languagerepo.Entity;
                    }

                    RolUserRepository objus = new RolUserRepository(this.session);
                    objus.Entity.UserId = this.Userrepository.Entity.UserId;
                    IList <RolUser> coll = objus.GetAllReadOnly();
                    List <Domain.Entities.Modul> moduls = CustomMemberShipProvider.GetModuls(this.Userrepository.Entity.UserId.Value, this.session, context);
                    string isFrontEndAdmin = "false";
                    if (moduls.Exists(t => t.ModulId == 57))
                    {
                        isFrontEndAdmin = "true";
                    }

                    StringBuilder strbRoles = new StringBuilder();

                    foreach (RolUser item in coll)
                    {
                        strbRoles.Append(item.RolId.ToString() + "-");
                    }

                    Utils.SetUserRewardAction(this.Userrepository.Entity.UserId.Value, RewardAction.UserActionType.Login, 2, 1, this.session, context, true, languagerepo.Entity);
                    this.Userrepository.Load();

                    this.Createticket(
                        strbRoles,
                        this.Userrepository.Entity.Names,
                        this.Userrepository.Entity.UserId.Value,
                        this.Userrepository.Entity.Email,
                        this.Userrepository.Entity.Image,
                        this.Userrepository.Entity.Medallos,
                        isFrontEndAdmin);

                    return(AuthencReturn.USER_OK);
                }
                else if (this.Userrepository.Entity.UserId != null && this.Userrepository.Entity.Active == false)
                {
                    return(AuthencReturn.USER_BLOCKED);
                }
                else
                {
                    return(AuthencReturn.NOT_FOUND);
                }
            }
            catch (Exception ex)
            {
                Utils.InsertLog(
                    this.session,
                    "Error Validando Usuario",
                    ex.Message + " " + ex.StackTrace);
                return(AuthencReturn.ERROR);
            }
        }