private void OnUserAvatarClicked(PublicUser publicUser)
 {
     if (GetSocial.User.Id.Equals(publicUser.Id))
     {
         var popup = new MNPopup("Action", "Choose Action");
         popup.AddAction("Show My Feed", OpenMyGlobalFeed);
         popup.AddAction("Cancel", () => { });
         popup.Show();
     }
     else
     {
         GetSocial.User.IsFriend(publicUser.Id, isFriend =>
         {
             if (isFriend)
             {
                 var popup = new MNPopup("Action", "Choose Action");
                 popup.AddAction("Show " + publicUser.DisplayName + " Feed", () => OpenUserGlobalFeed(publicUser));
                 popup.AddAction("Remove from Friends", () => RemoveFriend(publicUser));
                 popup.AddAction("Cancel", () => { });
                 popup.Show();
             }
             else
             {
                 var popup = new MNPopup("Action", "Choose Action");
                 popup.AddAction("Show " + publicUser.DisplayName + " Feed", () => OpenUserGlobalFeed(publicUser));
                 popup.AddAction("Add to Friends", () => AddFriend(publicUser));
                 popup.AddAction("Cancel", () => { });
                 popup.Show();
             }
         }, error => _console.LogE("Failed to check if friends with " + publicUser.DisplayName + ", error:" + error.Message));
     }
 }
Exemplo n.º 2
0
        public ActionResult changepass(string password, string repassword)
        {
            if (Request.Cookies.Get("sotp") != null)
            {
                if (password.Equals(repassword))
                {
                    string     email = Request.Cookies["temail"].Value.ToString();
                    PublicUser pu    = db.pus.Where(p => p.UserEmail == email).FirstOrDefault();
                    pu.Password     = password;
                    pu.ConfPassword = password;
                    db.SaveChanges();

                    Response.Cookies["rotp"].Expires   = DateTime.Now.AddDays(-1);
                    Response.Cookies["temail"].Expires = DateTime.Now.AddDays(-1);
                    ViewBag.msg1 = "Password Changed Successfully. Login by New Password";
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewBag.msg = "Both password must be same!!!";
                    return(View());
                }
            }
            else
            {
                return(RedirectToAction("forgot", "PULogin"));
            }
        }
Exemplo n.º 3
0
        public IEnumerable <PublicUser> GetUsers([FromBody] IEnumerable <string> userIds)
        {
            foreach (string userId in userIds)
            {
                var user       = StateManager.Db.GetUser(userId);
                var publicUser = new PublicUser
                {
                    UserId    = user.UserId,
                    AvatarUrl = user.AvatarUrl,
                    Name      = "Guest"
                };
                if (!string.IsNullOrWhiteSpace(user.DisplayName))
                {
                    publicUser.Name = user.DisplayName;
                }
                else if (!string.IsNullOrWhiteSpace(user.UserName))
                {
                    publicUser.Name = user.UserName;
                }
                else if (user.SpotifyUser != null && !string.IsNullOrWhiteSpace(user.SpotifyUser.DisplayName))
                {
                    publicUser.Name = user.SpotifyUser.DisplayName;
                }

                yield return(publicUser);
            }
        }
Exemplo n.º 4
0
        public ActionResult Register(MemberModel model)
        {
            var member = MemberModeMapper.Map(model);
            var error  = MemberHandler.AddMember(member);

            if (error == ErrorCode.ErrorWhileMemberRegistrationEmailEmpty)
            {
                ViewBag.RegstrationError = "Email address can't be empty.";
                return(View("Login"));
            }

            if (error == ErrorCode.ErrorWhileMemberRegistrationPasswordEmpty)
            {
                ViewBag.RegstrationError = "Password can't be empty.";
                return(View("Login"));
            }

            if (error == ErrorCode.ErrorWhileMemberRegistrationEmailAlreadyExist)
            {
                ViewBag.RegstrationError = "Email address already registerd.";
                return(View("Login"));
            }

            Session[Constants.AppUserKeyName] = PublicUser.GetCurrentUser(member);
            return(RedirectToAction("Index", "Home", new { area = "" }));
        }
Exemplo n.º 5
0
        public ApiResponse EditMobile([FromBody] UserReq model)
        {
            if (string.IsNullOrEmpty(model.Phone))
            {
                return(new ApiResponse(Metas.Phone_NULL));
            }

            if (string.IsNullOrEmpty(model.Captcha) || userBll.CheckCaptcha(model.Phone, model.Captcha, model.Type) == 0)
            {
                return(new ApiResponse(Metas.Captcha_Wrong));
            }
            PublicUser telUser = ncBase.CurrentEntities.PublicUser.Where(u => u.Tel == model.Phone).FirstOrDefault();

            if (telUser.IsNoNull())
            {
                return(new ApiResponse(Metas.Phone_EXISTS));
            }
            int        userId    = GetCurrentUserId();
            PublicUser loginUser = ncBase.CurrentEntities.PublicUser.Where(u => u.UserID == userId).FirstOrDefault();

            loginUser.Tel = model.Phone;
            ncBase.CurrentEntities.SaveChanges();

            return(new ApiResponse(Metas.SUCCESS));
        }
Exemplo n.º 6
0
        public JsonResult ResetPwd(int id = 0)
        {
            PublicUser publicUser = ncBase.CurrentEntities.PublicUser.Where(o => o.UserID == id).FirstOrDefault();

            if (publicUser.IsNull())
            {
                return(Json(new { status = 1, msg = "没有找到用户!(用户ID:" + id + ")" }));
            }
            string passWordAdorn = ConfigUtility.GetValue("PassWordAdorn");
            string passWord      = string.Empty;

            if (string.IsNullOrEmpty(publicUser.Tel))
            {
                passWord = Convert.ToString(publicUser.UserID);
            }
            PublicUserModel loginUser = this.GetLoginUser();

            passWord            = publicUser.Tel;
            publicUser.Password = StringUtility.ToMd5String(passWordAdorn + passWord);
            ncBase.CurrentEntities.SaveChanges();
            OperatorLog operatorLog = new OperatorLog();

            operatorLog.Note    = "重置密码,被重置用户ID:" + publicUser.UserID + " 新密码:" + passWord;
            operatorLog.Type    = 1;
            operatorLog.Uid     = loginUser.UserID;
            operatorLog.AddTime = DateTime.Now;
            ncBase.CurrentEntities.AddToOperatorLog(operatorLog);
            ncBase.CurrentEntities.SaveChanges();

            return(Json(new { status = 0, msg = "密码重置成功, 新密码:" + passWord }));
        }
Exemplo n.º 7
0
        public ApiResponse EditPortrait([FromBody] UserReq model)
        {
            int    userId        = GetCurrentUserId();
            int    gainPoints    = 0;
            string gainPointsMsg = "";

            if (string.IsNullOrEmpty(model.Portrait))
            {
                return(new ApiResponse(Metas.Portrait_NULL));
            }
            PublicUser thisUser = ncBase.CurrentEntities.PublicUser.Where(o => o.UserID == userId).FirstOrDefault();

            if (thisUser.IsNoNull())
            {
                thisUser.Portrait = model.Portrait;
                ncBase.CurrentEntities.SaveChanges();

                DoTask(userId, PointsEnum.First_UploadHead, out gainPoints);
                gainPointsMsg = "完成“有头有脸”任务";
            }

            var result = new
            {
                GainPoints    = gainPoints,
                GainPointsMsg = gainPointsMsg
            };

            return(new ApiResponse(Metas.SUCCESS, result));
        }
Exemplo n.º 8
0
        public ActionResult DoChangeEmail(string validCode)
        {
            PublicUserModel    user   = this.GetLoginUser();
            int                status = 0;
            EmailEditValidCode item   = ncBase.CurrentEntities.EmailEditValidCode.Where(e => e.Code == validCode && e.Status == 0 && e.UserId == user.UserID).OrderByDescending(e => e.AddTime).FirstOrDefault();

            if (item.IsNoNull())
            {
                PublicUser thisUser = ncBase.CurrentEntities.PublicUser.Where(u => u.UserID == user.UserID).FirstOrDefault();
                if (thisUser.IsNoNull())
                {
                    thisUser.Email = item.NewEmail;
                    item.Status    = 1;
                    ncBase.CurrentEntities.SaveChanges();
                    status = 1;
                }
                else
                {
                    status = -100;//用户不存在
                }
            }
            else
            {
                status = -99;//不是有效的邮箱验证
            }
            ViewBag.status = status;
            return(View());
        }
Exemplo n.º 9
0
        public ViewResult ChangeEmail(UserFull userModification)
        {
            UserEmail userEmail = new UserEmail(userModification);
            var       errors    = userEmail.Validate();

            if (errors == null)
            {
                if (registeredUserRepository.GetByMail(userModification.Email) == null)
                {
                    MembershipUser mu = Membership.GetUser();
                    PublicUser     ru = (PublicUser)registeredUserRepository.GetByMembershipId(Convert.ToInt32(mu.ProviderUserKey));
                    mu.Email        = userModification.Email;
                    ru.EmailAddress = userModification.Email;
                    registeredUserRepository.SaveOrUpdate(ru);
                    userModification.Alert = "User email updated successfully";
                }
                else
                {
                    errors = new ErrorSummary();
                    errors.RegisterErrorMessage("Email", "That email already exist in our database");
                }
            }

            if (errors != null)
            {
                Session["Errors"] = errors.ErrorMessages;
            }

            userModification.Tab = 1;
            userModification     = GetAccountData(userModification);
            return(View("Index", userModification));
        }
Exemplo n.º 10
0
        public virtual string GetUserName(int uid)
        {
            string name = string.Empty;

            PublicUser userInfo = ncBase.CurrentEntities.PublicUser.Where(s => s.UserID == uid).FirstOrDefault();  //获取单条数据


            //int pageIndex = 0; //第几页 0 第一页
            //int pageSize = 10;
            //List<PublicUser> userList =
            //    ncBase.CurrentEntities.PublicUser.Where(s => s.Status == 1)
            //        .OrderByDescending(s => s.RegisterTime)
            //        .Skip(pageIndex*pageSize)
            //        .Take(pageSize)
            //        .ToList();

            //if (userList.IsNoNull())
            //{
            //  //ToDo:业务逻辑
            //}

            if (userInfo.IsNoNull())
            {
                name = userInfo.Name;
            }
            return(name);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Додава нова Мастер Админ
        /// </summary>
        /// <returns></returns>
        protected override ActionResult Add()
        {
            try
            {
                if (ModelState.IsValid)
                {
                    PublicUser newUser;
                    //SendWelcomeEmailToUserViewModel sendWelcomeEmailToUserViewModel;
                    using (var scope = new UnitOfWorkScope())
                    {
                        var user = _userRepository.GetUserByUsername(GridModel.UserName);
                        if (user != null)
                        {
                            throw new DuplicateKeyException();
                        }

                        //Generate the Password
                        string password    = new PasswordGenerator().Generate();
                        string passwordEnc = password.Md5String();

                        //Create new User
                        var lang = _langRepository.Get(GridModel.PreferedLanguage);

                        newUser = new PublicUser(GridModel.UserName, passwordEnc, GridModel.FirstName, GridModel.LastName, lang);
                        //newUser.AddToPos(pos);
                        newUser.IsActive = GridModel.IsActive;
                        var role = _roleRepository.GetRoleByName(Roles.Admin);
                        newUser.AddToRole(role);



                        //Get the Pos
                        //int posId = Convert.ToInt32(GridModel.Pos);
                        //Pos pos = _posRepository.Get(posId);
                        //newUser.AddToPos(pos);

                        //sendWelcomeEmailToUserViewModel = new SendWelcomeEmailToUserViewModel
                        //{
                        //    FullName = newUser.FullName,
                        //    Password = password
                        //};

                        //Save It
                        _publicUserRepository.Save(newUser);
                        scope.Commit();
                    }

                    ////Send Welcome email to created administrator
                    //sendWelcomeEmailToUserViewModel.To = newUser.UserName;
                    //MailService.SendWelcomeEmailToUser(sendWelcomeEmailToUserViewModel);

                    return(Json(GridModel));
                }
            }
            catch (DuplicateKeyException)
            {
                ModelState.AddModelError(string.Empty, string.Format("Корисникот со корисничко име {0} веќе постои во системот.", GridModel.UserName));
            }
            throw CreateModelException(GridModel);
        }
        void onAvatarClicked(AndroidJavaObject publicUserAjo)
        {
            Debug.Log(">>>>>>> XXXX");
            var publicUser = new PublicUser().ParseFromAJO(publicUserAjo);

            ExecuteOnMainThread(() => _avatarClickListener(publicUser));
        }
Exemplo n.º 13
0
        public async Task GetState([QueryField] bool?json, string tokenArg)
        {
            (ChatId, UserId)? token = ApiMessenger.ParseToken(tokenArg);
            if (token == null)
            {
                throw HttpException.Forbidden();
            }

            var(_, user) = ((ChatId, UserId))token;

            using var context = new UserContext(user);
            var publicUser = new PublicUser(context.User);
            var bytes      = MessagePackSerializer.Serialize(publicUser);

            if (json ?? false)
            {
                var response = MessagePackSerializer.ConvertToJson(bytes);
                HttpContext.Response.ContentType = "application/json";
                bytes = Encoding.UTF8.GetBytes(response);
            }
            else
            {
                HttpContext.Response.ContentType = "application/x-msgpack";
            }
            using (var stream = HttpContext.OpenResponseStream())
            {
                await stream.WriteAsync(bytes, 0, bytes.Length);
            }
        }
Exemplo n.º 14
0
    protected override async void OnSpotifyConnectionChanged(SpotifyClient client)
    {
        base.OnSpotifyConnectionChanged(client);

        if (client != null)
        {
            // Check if we are authorized to read private profile information
            if (string.IsNullOrEmpty(UserId))
            {
                if (SpotifyService.Instance.AreScopesAuthorized(Scopes.UserReadPrivate))
                {
                    _privateUserInfo = await client.UserProfile.Current();
                }
                else
                {
                    Debug.LogError($"Not authorized to access '{Scopes.UserReadPrivate}'");
                }
            }
            else
            {
                _publicUserInfo = await client.UserProfile.Get(UserId);
            }
        }
        else
        {
            _privateUserInfo = null;
            _publicUserInfo  = null;
        }

        UpdateUI();
    }
Exemplo n.º 15
0
        public ApiResponse EditEnrolnName([FromBody] UserReq model)
        {
            int    userId        = GetCurrentUserId();
            int    gainPoints    = 0;
            string gainPointsMsg = "";

            if (string.IsNullOrEmpty(model.EnrolnName))
            {
                return(new ApiResponse(Metas.Info_NULL));
            }
            if (model.EnrolnName.Length < 2 || model.EnrolnName.Length > 6)
            {
                return(new ApiResponse(Metas.EnrolnName_LengthError));
            }
            PublicUser thisUser = ncBase.CurrentEntities.PublicUser.Where(o => o.UserID == userId).FirstOrDefault();

            if (thisUser.IsNoNull())
            {
                thisUser.EnrolnName = model.EnrolnName;
                ncBase.CurrentEntities.SaveChanges();

                DoTask(userId, PointsEnum.First_EnrolnName, out gainPoints);
                gainPointsMsg = "完成“修改真实姓名”任务";
            }

            var result = new
            {
                GainPoints    = gainPoints,
                GainPointsMsg = gainPointsMsg
            };

            return(new ApiResponse(Metas.SUCCESS, result));
        }
Exemplo n.º 16
0
        public PublicUser ValidateVerificationToken(string token)
        {
            PublicUser result = null;
            TokenValidationParameters validation = new TokenValidationParameters()
            {
                ValidateIssuer           = true,
                ValidateLifetime         = true,
                ValidateAudience         = true,
                ValidateIssuerSigningKey = true,
                ValidIssuer      = _config["Jwt:Issuer"],
                ValidAudience    = _config["Jwt:Audience"],
                IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Jwt:KeyForMail"]))
            };
            SecurityToken returnedToken = null;

            var             handler   = new JwtSecurityTokenHandler();
            ClaimsPrincipal jsonToken = null;

            try
            {
                jsonToken = handler.ValidateToken(token, validation, out returnedToken);
                int temp = -1;
                int.TryParse(jsonToken.Claims.ElementAt(0).Value, out temp);
                result = new PublicUser()
                {
                    Id       = temp,
                    Username = jsonToken.Claims.ElementAt(1).Value
                };
            }
            catch {
                throw;
            }
            return(result);
        }
Exemplo n.º 17
0
        public static PublicUserDTO ToPublicUserDto(this PublicUser input)
        {
            if (input == null)
            {
                return(null);
            }

            return(new PublicUserDTO()
            {
                Mail = input.Mail,
                Id = input.UserId,
                FullName = input.FullName,
                Username = input.Username,
                EncPassword = input.Password,
                IsActive = input.IsActive.Value,
                Phone = input.Phone,
                Salt = input.Salt,
                Birthdate = input.Birthdate.Value,
                IdentityNumber = input.IdentityNumber,
                ImageUrl = input.ImageURL,
                Issuedate = input.IssueDate.Value,
                NationalityId = input.NationalityId.Value,
                NotificationToken = input.NotificationToken,
            });
        }
Exemplo n.º 18
0
        public ActionResult signup([Bind(Include = "PublicUserId,UserName,UserEmail,Password,ConfPassword,AadharNo")] PublicUser publicUser)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.msg = "Password and Conform Password must be same!!!";
                return(View());
            }
            else
            {
                PublicUser pu1 = db.pus.Where(p => p.UserEmail == publicUser.UserEmail).FirstOrDefault();
                PublicUser pu2 = db.pus.Where(p => p.AadharNo == publicUser.AadharNo).FirstOrDefault();
                if (pu1 != null)
                {
                    ViewBag.msg = "Account already exist for given email!!!";
                    return(View());
                }
                else if (pu2 != null)
                {
                    ViewBag.msg = "Account already exist for given Aadhar No!!!";
                    return(View());
                }
                else
                {
                    Response.Cookies.Add(new HttpCookie("temail", publicUser.UserEmail));
                    Response.Cookies.Add(new HttpCookie("tname", publicUser.UserName));
                    Response.Cookies.Add(new HttpCookie("tpass", publicUser.Password));
                    Response.Cookies.Add(new HttpCookie("aadharno", publicUser.AadharNo));
                    try
                    {
                        Random rnd = new Random();
                        string se, sp, sub, body;
                        long   otp = rnd.Next(100000, 999999);
                        Session["sotp"] = otp;
                        se   = "*****@*****.**";
                        sp   = "Devendra@285";
                        sub  = "OTP for SIGN UP in e-Parivahan";
                        body = "<h3>Welcome " + publicUser.UserName + "</h3><p><b>OTP is " + otp.ToString() + "</b> for verify your email in e-Parivahan account.Please do not share with anyone.</p><p>Thank You!!</p>";
                        SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
                        client.EnableSsl             = true;
                        client.Timeout               = 100000;
                        client.DeliveryMethod        = SmtpDeliveryMethod.Network;
                        client.UseDefaultCredentials = false;
                        client.Credentials           = new NetworkCredential(se, sp);

                        MailMessage mm = new MailMessage(se, publicUser.UserEmail, sub, body);
                        mm.IsBodyHtml   = true;
                        mm.BodyEncoding = UTF8Encoding.UTF8;

                        client.Send(mm);
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }
                    Response.Cookies.Add(new HttpCookie("rotp", "signup"));
                    return(RedirectToAction("OTP", "PULogin"));
                }
            }
        }
Exemplo n.º 19
0
 private async void enterChat(PublicUser user)
 {
     _observer.Stop();
     chat             = new MainForm(user, _stanIP);
     chat.FormClosed += showAuthForm;
     chat.Show();
     Hide();
 }
Exemplo n.º 20
0
        internal Comment(string description, PublicUser publicUser)
        {
            this.ValidateDescription(description);

            this.Description = description;
            this.PublicUser  = publicUser;
            this.CreatedOn   = DateTime.Now;
        }
        public ViewResult HomePage(int myid, Blog b)
        {
            string     name = HttpContext.Session.GetString("Name");
            int        id   = PublicUserRepo.GetId(name);
            PublicUser usr  = PublicUserRepo.getUserbyId(id);

            return(View(usr));
        }
Exemplo n.º 22
0
        public ActionResult Index()
        {
            var member      = PublicUser.GetCurrentUser();
            var list        = OrderHandler.GetOrders(member.MemberId);
            var orderModels = list.Select(OrderModelMapper.Map).ToList();

            return(View(orderModels));
        }
Exemplo n.º 23
0
        public ActionResult DeleteConfirmed(int id)
        {
            PublicUser publicUser = db.PublicUsers.Find(id);

            db.PublicUsers.Remove(publicUser);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 24
0
        public async Task <IActionResult> RefreshProfile()
        {
            PublicUser currentUser = (PublicUser)ViewData["User"];

            await UserProfile.RefreshPublicUserProfile(currentUser.UserId, _settings, _redis);

            return(RedirectToAction("SelfProfile"));
        }
        public ActionResult Index()
        {
            if (Request.Cookies.Get("uid") != null)
            {
                string temp = Request.Cookies["uemail"].Value.ToString();

                pu         = db.pus.Where(p => p.UserEmail == temp).FirstOrDefault();
                ViewBag.pu = pu;

                if (pu.isDLPresent == true)
                {
                    dls         = pu.dl;
                    ViewBag.dls = dls;
                }
                else
                {
                    ViewBag.dls        = null;
                    ViewBag.ChallanMsg = "NO CHALLANS";
                }



                if (pu.isRCPresent == true)
                {
                    rcs         = pu.rc;
                    ViewBag.rcs = rcs;
                }
                else
                {
                    ViewBag.rcs        = null;
                    ViewBag.ChallanMsg = "NO CHALLANS";
                }


                //if (rc != null)
                //{
                //    rcc = db.Challans.Where(c => c.RegNo == rc.RegNo).ToList();
                //    ViewBag.rcc = rcc;
                //}

                if (pu.isPUCPresent != false)
                {
                    pucs         = pu.puc;
                    ViewBag.pucs = pucs;
                }
                else
                {
                    ViewBag.pucs       = null;
                    ViewBag.ChallanMsg = "NO CHALLANS";
                }

                return(View());
            }
            else
            {
                return(RedirectToAction("Index", "PULogin"));
            }
        }
        public override PlaylistTrack Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            if (reader.TokenType is not JsonTokenType.StartObject)
            {
                throw new JsonException();
            }

            var playableConverter   = options.GetConverter <IPlayable>();
            var publicUserConverter = options.GetConverter <PublicUser>();

            DateTime   addedAt = default;
            PublicUser addedBy = null !;
            bool       isLocal = default;
            IPlayable  track   = null !;

            while (reader.Read())
            {
                if (reader.TokenType is JsonTokenType.EndObject)
                {
                    break;
                }

                if (reader.TokenType is not JsonTokenType.PropertyName)
                {
                    throw new JsonException();
                }

                var propertyName = reader.GetString();

                reader.Read(); // Read to next token.

                switch (propertyName)
                {
                case "added_at":
                    addedAt = reader.GetDateTime();
                    break;

                case "added_by":
                    addedBy = publicUserConverter.Read(ref reader, typeof(PublicUser), options) !;
                    break;

                case "is_local":
                    isLocal = reader.GetBoolean();
                    break;

                case "track":
                    track = playableConverter.Read(ref reader, typeof(IPlayable), options) !;
                    break;

                default:
                    reader.Skip();
                    break;
                }
            }

            return(new(addedAt, addedBy, isLocal, track));
        }
Exemplo n.º 27
0
        public void register(PublicUser remoteUser)
        {
            var account = new Account(remoteUser.uuid);

            using (var db = serverContext.getDbContext()) {
                db.accounts.Add(account);
                db.SaveChanges();
            }
        }
Exemplo n.º 28
0
        public void AdmiCatalogue()
        {
            ManageBook bookFunction = new ManageBook();
            PublicUser manageUser   = new PublicUser();



START:
            Console.WriteLine("");
            Console.WriteLine("|============================================|");
            Console.WriteLine("|              ADMIN:CATALOGUE               |");
            Console.WriteLine("|============================================|");
            Console.WriteLine("| 1.View Books                               |");
            Console.WriteLine("| 2.Add Books                                |");
            Console.WriteLine("| 3.Insert Books                             |");
            Console.WriteLine("| 4.Remove Books                             |");
            Console.WriteLine("| 5.View Public User Log.                    |");
            Console.WriteLine("| 6.Exit                                     |");
            Console.WriteLine("|============================================|");
            Console.WriteLine("| PLEASE CHOOSE ACCORDINGLY : INPUT A NUMBER |");
            Console.WriteLine("|============================================|");
            Console.WriteLine("");

            int adminInput = int.Parse(Console.ReadLine());

            if (adminInput == 1)
            {
                bookFunction.BookView();
                goto START;
            }
            else if (adminInput == 2)
            {
                bookFunction.BookAdd();
                goto START;
            }
            else if (adminInput == 3)
            {
                bookFunction.BookInsert();
                goto START;
            }
            else if (adminInput == 4)
            {
                bookFunction.BookRemoved();
                goto START;
            }
            else if (adminInput == 5)
            {
                manageUser.ViewUserLog();
                goto START;
            }


            else
            {
                Console.WriteLine("Admin Catalogue Shuting down ... ");
            }
        }
        public ActionResult Remove(int id, string number)
        {
            if (Request.Cookies.Get("uid") != null)
            {
                string temp = Request.Cookies["uemail"].Value.ToString();

                pu = db.pus.Where(p => p.UserEmail == temp).FirstOrDefault();

                if (id == 1)
                {
                    DL tdl = db.DLs.Where(p => p.LicenceNo.Equals(number)).FirstOrDefault();
                    pu.dl.Remove(tdl);
                    if (pu.dl.Count == 0)
                    {
                        pu.isDLPresent = false;
                    }
                    else
                    {
                        pu.isDLPresent = true;
                    }
                }
                else if (id == 2)
                {
                    RC trc = db.Rcs.Where(p => p.VehicleNo.Equals(number)).FirstOrDefault();
                    pu.rc.Remove(trc);
                    if (pu.rc.Count == 0)
                    {
                        pu.isRCPresent = false;
                    }
                    else
                    {
                        pu.isRCPresent = true;
                    }
                }
                else if (id == 3)
                {
                    PUC tpuc = db.PUCs.Where(p => p.PUCNo.Equals(number)).FirstOrDefault();
                    pu.puc.Remove(tpuc);
                    if (pu.puc.Count == 0)
                    {
                        pu.isPUCPresent = false;
                    }
                    else
                    {
                        pu.isPUCPresent = true;
                    }
                }
                db.SaveChanges();
                //alert "Successfully Removed Virtual Document!!"
                return(RedirectToAction("Index", "PUHome"));
            }
            else
            {
                return(RedirectToAction("Index", "PULogin"));
            }
        }
Exemplo n.º 30
0
        public JsonResult EditEmail(string email)
        {
            if (string.IsNullOrEmpty(email))
            {
                return(Json(new { status = 1, msg = "邮箱不能为空" }));
            }
            PublicUser emailUser = ncBase.CurrentEntities.PublicUser.Where(u => u.Email == email).FirstOrDefault();

            if (emailUser.IsNoNull())
            {
                return(Json(new { status = 1, msg = "修改失败,该邮箱已被使用" }));
            }
            PublicUserModel user   = this.GetLoginUser();
            int             userId = this.GetLoginUser().UserID;

            //#region 直接修改
            //PublicUserModel user = this.GetLoginUser();
            //int userId = this.GetLoginUser().UserID;
            //PublicUser loginUser = ncBase.CurrentEntities.PublicUser.Where(u => u.UserID == userId).FirstOrDefault();
            //loginUser.Email = email;
            //ncBase.CurrentEntities.SaveChanges();
            //#endregion
            #region 发送邮箱进行验证后,在验证页面进行修改
            string md5Code = ZJB.Core.Utilities.StringUtility.ToMd5String(userId.ToString() + email + DateTime.Now.ToString());

            EmailEditValidCode ValidRecord = ncBase.CurrentEntities.EmailEditValidCode.Where(e => e.UserId == userId).FirstOrDefault();
            if (ValidRecord.IsNoNull())
            {
                ValidRecord.NewEmail = email;
                ValidRecord.Status   = 0;
                ValidRecord.AddTime  = DateTime.Now;
                ValidRecord.Code     = md5Code;
                ncBase.CurrentEntities.SaveChanges();
            }
            else
            {
                EmailEditValidCode newValid = new EmailEditValidCode()
                {
                    AddTime  = DateTime.Now,
                    Code     = md5Code,
                    NewEmail = email,
                    Status   = 0,
                    UserId   = userId,
                };
                ncBase.CurrentEntities.EmailEditValidCode.AddObject(newValid);
                ncBase.CurrentEntities.SaveChanges();
            }
            ZJB.Core.Utilities.EmailSender emailHelper = new EmailSender();
            string title     = "修改邮箱验证";
            string url       = "http://" + Request.Url.Host + "/User/DoChangeEmail" + "?validCode=" + md5Code;
            string updateUrl = "<a target='_blank' href=\"" + url + "\">前往修改</a>";
            string content   = string.Format(ConfigUtility.GetValue("ChangeEamilConent"), user.Name, updateUrl);
            SendEmail(title, content, email);
            #endregion
            return(Json(new { status = 0, msg = "邮箱验证已发送到您新的邮箱,请查收" }));
        }