Ejemplo n.º 1
0
        public ActionResult ChangeProfileAvatar(HttpPostedFileBase fileUserProfile, string UserId)
        {
            try
            {
                //Int64 userid = new UserSession().getUserSession().UserId;
                string USER_id = new SecurityManager().DecodeString(UserId);
                User Old_userObj = new User().GetUser(Convert.ToInt64(USER_id));
                string savedFileName = "";
                if (fileUserProfile != null)
                {
                    savedFileName = uploadProfileImage(fileUserProfile);
                    if (!string.IsNullOrWhiteSpace(savedFileName))
                    {
                        string filename = new User().ChangeProfilePhoto(Old_userObj.UserId, savedFileName);
                        //New_userObj.ProfilePhoto = savedFileName;
                        deleteUploadedImage(filename);
                        User retObj = new User().AuthnticateUser(Old_userObj);
                        if (retObj != null)
                        {
                            new UserSession().SetUserSession(retObj);
                        }

                    }
                }
                Old_userObj = null;
            }
            catch (Exception)
            {
            }
            return RedirectToRoute(new RouteValueDictionary(new { controller = "ShopImages", action = "Index", Id = UserId }));
        }
Ejemplo n.º 2
0
        public ActionResult AddShopImage(HttpPostedFileBase ShopImageFile, string txtImageTitle, string chkSlider, string UserId)
        {
            try
            {
                string USER_id = new SecurityManager().DecodeString(UserId);
                User UserObj = new User().GetUser(Convert.ToInt64(USER_id));
                string savedFileName = "";
                if (ShopImageFile != null)
                {
                    savedFileName = uploadProfileImage(ShopImageFile, UserObj.UserId);
                    if (!string.IsNullOrWhiteSpace(savedFileName))
                    {

                        Shop_Image shopImage = new Shop_Image();
                        shopImage.User_Id = UserObj.UserId;
                        shopImage.Image_Title = txtImageTitle;
                        shopImage.Image_Path = savedFileName;
                        shopImage.Is_For_Home_Page_Slider = false;
                        shopImage.Created_On = DateTime.Now;
                        if (!string.IsNullOrWhiteSpace(chkSlider) && chkSlider.Equals("1"))
                        {
                            shopImage.Is_For_Home_Page_Slider = true;
                        }
                        shopImage.AddShopImage(shopImage);
                        shopImage = null;
                    }
                }
                UserObj = null;
            }
            catch (Exception)
            {
            }
            return RedirectToRoute(new RouteValueDictionary(new { controller = "ShopImages", action = "Index", Id = UserId }));
        }
Ejemplo n.º 3
0
        public ActionResult getCaptchaImage(string captchaString)
        {
            var rand = new Random((int)DateTime.Now.Ticks);

            //generate new question
            int a = rand.Next(10, 99);
            int b = rand.Next(0, 9);

            captchaString = new SecurityManager().DecodeString(captchaString);
            var captcha = captchaString;

            //image stream
            FileContentResult img = null;

            using (var mem = new MemoryStream())
            using (var bmp = new Bitmap(Constants.CAPTCHA_WIDTH, Constants.CAPTCHA_HIGHT))
            using (var gfx = Graphics.FromImage((Image)bmp))
            {
                gfx.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
                gfx.SmoothingMode = SmoothingMode.AntiAlias;

                PointF oPoint = new PointF(2f, 2f);
                SolidBrush oBrushWrite = new SolidBrush(Color.Red);
                SolidBrush oBrush = new SolidBrush(Color.White);
                gfx.FillRectangle(oBrush, 0, 0, bmp.Width, bmp.Height);

                //gfx.FillRectangle(new SolidBrush(Color.White), new Rectangle(0, 0, bmp.Width, bmp.Height));

                //add noise
                // if (noisy)
                // {
                int i, r, x, y;
                var pen = new Pen(Color.Yellow);
                for (i = 1; i < 100; i++)
                {
                    pen.Color = Color.FromArgb(
                    (rand.Next(0, 255)),
                    (rand.Next(0, 255)),
                    (rand.Next(0, 255)));

                    r = rand.Next(0, (Constants.CAPTCHA_WIDTH / 4));
                    x = rand.Next(0, Constants.CAPTCHA_WIDTH);
                    y = rand.Next(0, Constants.CAPTCHA_HIGHT);
                    gfx.DrawEllipse(pen, x, y, 2, 2);

                }
                //  }

                //add question
                Font oFont = new Font("Tahoma", Constants.CAPTCHA_FONT_SIZE, FontStyle.Regular);
                gfx.DrawString(captcha, oFont, Brushes.Red, 2, 3);

                //render as Jpeg
                bmp.Save(mem, System.Drawing.Imaging.ImageFormat.Jpeg);
                img = this.File(mem.GetBuffer(), "image/Jpeg");
            }

            return img;
        }
Ejemplo n.º 4
0
        public ActionResult ActivateMe(string mySite)
        {
            try
            {
                if (!string.IsNullOrEmpty(mySite))
                {
                    string UserId = new SecurityManager().DecodeString(mySite);
                    Boolean retResult = new User().ChangeUserStatus(Convert.ToInt64(UserId), Convert.ToInt16(UserStatusType.Active));
                    if (retResult == true)
                    {
                        ViewData.Model = new User().GetUser(Convert.ToInt64(UserId));

                    }

                }
            }
            catch (Exception)
            {

            }
            return View("UserActivation");
        }
Ejemplo n.º 5
0
        public ActionResult CreateGroup(string groupId)
        {
            ViewData[Constants.MENU_PARENT] = Constants.MENU_MANAGE_GROUPS;
            ViewData[Constants.MENU] = Constants.CREATE_GROUP;
            ViewBag.TitleDes = "Free shop advertisement";

            //List<Group> g = new List<Group>();
            if (!string.IsNullOrWhiteSpace(groupId))
            {
                string GroupId = new SecurityManager().DecodeString(groupId);
                Group g = new Group().getsingleGroup(Convert.ToInt64(GroupId));
                ViewData["txtGroupName"] = g.Name;
                ViewData["txtDescription"] = g.GroupDescription;
                ViewData["radType"] = g.GroupType;
                ViewData["hidGroupId"] = groupId;
            }
            return View();
        }
Ejemplo n.º 6
0
        public ActionResult AddNewsForm(string RecSaveOperation, string hidNewsId)
        {
            try
            {
                if (!String.IsNullOrWhiteSpace(hidNewsId))
                {
                    ViewData[Constants.MENU_PARENT] = Constants.MENU_MANAGE_NEWS;
                    ViewData[Constants.MENU] = Constants.MANAGE_NEWS;

                    string News_Id = new SecurityManager().DecodeString(hidNewsId);

                    Shop_New SN = new Shop_New().GetShopNews(Convert.ToInt64(News_Id));
                    ViewData["txtNewsHeadLine"] = SN.News_HeadLine;
                    ViewData["txtNewsDetail"] = SN.News_Detail;
                    ViewData["hidNewsId"] = hidNewsId;
                }
                else
                {
                    ViewData[Constants.MENU_PARENT] = Constants.MENU_MANAGE_NEWS;
                    ViewData[Constants.MENU] = Constants.ADD_NEWS;

                    ViewBag.TitleDes = "Free shop advertisement";
                    if (!String.IsNullOrEmpty(RecSaveOperation))
                    {
                        ViewData[Constants.OPERATIONALMESSAGE] = Utils.getSuccessMessage("Success", "Record saved successfully.");
                    }
                }
            }
            catch(Exception ex)
            { }
            return View("AddNews");
        }
Ejemplo n.º 7
0
 //public ActionResult EditShopNews(string NewsId)
 //{
 //    ViewData[Constants.MENU_PARENT] = Constants.MENU_MANAGE_NEWS;
 //    ViewData[Constants.MENU] = Constants.MANAGE_NEWS;
 //    ViewBag.TitleDes = "Free shop advertisement";
 //    string News_Id = new SecurityManager().DecodeString(NewsId);
 //    ViewData.Model = new Shop_New().GetShopNews(Convert.ToInt64(News_Id));
 //    return View("EditNews");
 //}
 public ActionResult DeleteNews(string NewsId)
 {
     try
     {
         if (!string.IsNullOrEmpty(NewsId))
         {
             string News_Id = new SecurityManager().DecodeString(NewsId);
             Boolean retItem = new Shop_New().DeleteNews(Convert.ToInt64(News_Id));
             if (retItem == true)
             {
                 return RedirectToRoute(new RouteValueDictionary(new { controller = "ShopNews", action = "ManageShopNews", RecDelOperation = "1" }));
             }
             else
             {
                 return RedirectToRoute(new RouteValueDictionary(new { controller = "ShopNews", action = "ManageShopNews", RecDelErrorOperation = "1" }));
             }
         }
     }
     catch (Exception)
     {
     }
     return RedirectToRoute(new RouteValueDictionary(new { controller = "ShopNews", action = "ManageShopNews" }));
 }
Ejemplo n.º 8
0
        public ActionResult RegisterShop(string txtShopName, string txtShopCountry, string txtShopCity, string txtShopAddress, string txtMapUrl, string txtShopDescription)
        {
            try
            {
                Boolean validInput = true;

                ViewData["txtShopName"] = txtShopName;
                ViewData["txtShopCountry"] = txtShopCountry;
                ViewData["txtShopCity"] = txtShopCity;
                ViewData["txtShopAddress"] = txtShopAddress;
                ViewData["txtMapUrl"] = txtMapUrl;
                ViewData["txtShopDescription"] = txtShopDescription;

                //my own
                if (string.IsNullOrWhiteSpace(txtShopName))
                {
                    validInput = false;
                    ViewData[Constants.OPERATIONALMESSAGE] = Utils.getErrorMessage("Input field required", "Please enter shop name");
                }
                if (string.IsNullOrWhiteSpace(txtShopCountry))
                {
                    validInput = false;
                    ViewData[Constants.OPERATIONALMESSAGE] = Utils.getErrorMessage("Input field required", "Please enter shop country name");
                }
                if (string.IsNullOrWhiteSpace(txtShopCity))
                {
                    validInput = false;
                    ViewData[Constants.OPERATIONALMESSAGE] = Utils.getErrorMessage("Input field required", "Please enter shop city name");
                }
                if (string.IsNullOrWhiteSpace(txtShopAddress))
                {
                    validInput = false;
                    ViewData[Constants.OPERATIONALMESSAGE] = Utils.getErrorMessage("Input field required", "Please enter shop address");
                }
                if (string.IsNullOrWhiteSpace(txtShopDescription))
                {
                    validInput = false;
                    ViewData[Constants.OPERATIONALMESSAGE] = Utils.getErrorMessage("Input field required", "Please enter shop description");
                }

                //limit

                if (validInput == true)
                {

                    Int64 userid = new UserSession().getUserSession().UserId;

                    User userObj = new User();
                    userObj.UserId = userid;
                    userObj.ShopName = txtShopName;
                    userObj.ShopCountry = txtShopCountry;
                    userObj.ShopCity = txtShopCity;
                    userObj.ShopAddress = txtShopAddress;
                    userObj.ShopMapUrl = txtMapUrl;
                    userObj.ShopDescription = txtShopDescription;
                    userObj.Shop_Last_Updated_On = DateTime.UtcNow;
                    userObj.Is_ShopCreated= true;
                    User retShop = new User().CreateShop(userObj);
                    if (retShop==null)
                    {
                        validInput = false;
                        ViewData[Constants.OPERATIONALMESSAGE] = Utils.getErrorMessage("Error", "Error occured during process Please try again");
                    }
                    else
                    {
                        string USER_ID = new ShopOnline.Common.SecurityManager().EncodeString(Convert.ToString(retShop.UserId));
                        new UserSession().SetUserSession(retShop);
                        return RedirectToRoute(new RouteValueDictionary(new { controller = "ShopImages", action = "Index", Id = USER_ID }));
                    }
                }
            }
            catch (Exception)
            {
            }

            return View("ShopRegister");
        }
Ejemplo n.º 9
0
        public ActionResult RegisterUser(string txtCaptchaCode, string txtLoginName, string txtEmail, string txtPassword, string txtConfirmPassword, string txtFirstName, string txtLastName, string txtContactNumber, string radGender, string txtDay, string txtMonth, string txtYear)
        {
            try
            {
                ViewBag.TitleDes = "Free shop advertisement";
                Boolean validInput = true;
                ViewData["txtLoginName"] = txtLoginName;
                ViewData["txtPassword"] = txtPassword;
                ViewData["txtConfirmPassword"] = txtConfirmPassword;
                ViewData["txtFirstName"] = txtFirstName;
                ViewData["txtLastName"] = txtLastName;
                ViewData["txtContactNumber"] = txtContactNumber;
                ViewData["txtEmail"] = txtEmail;

                ViewData["radGender"] = radGender;
                ViewData["txtDay"] = txtDay;
                ViewData["txtMonth"] = txtMonth;
                ViewData["txtYear"] = txtYear;

                if (string.IsNullOrWhiteSpace(txtCaptchaCode))
                {
                    validInput = false;
                    ViewData[Constants.OPERATIONALMESSAGE] = Utils.getErrorMessage("Input field required", "Please enter security code");
                }

                if (string.IsNullOrWhiteSpace(txtLoginName))
                {
                    validInput = false;
                    ViewData[Constants.OPERATIONALMESSAGE] = Utils.getErrorMessage("Input field required", "Please enter login name");
                }
                else
                {
                    if (new User().CheckUserAvailablity(txtLoginName.Trim()) == false)
                    {
                        validInput = false;
                        ViewData[Constants.OPERATIONALMESSAGE] = Utils.getErrorMessage("Sorry Login Name Not Available", "Sorry, Login name not available. Please try with different login name.");
                    }
                }

                if (string.IsNullOrWhiteSpace(txtEmail))
                {
                    validInput = false;
                    ViewData[Constants.OPERATIONALMESSAGE] = Utils.getErrorMessage("Input field required", "Please enter email");
                }

                if (string.IsNullOrWhiteSpace(txtPassword))
                {
                    validInput = false;
                    ViewData[Constants.OPERATIONALMESSAGE] = Utils.getErrorMessage("Input field required", "Please enter password");
                }
                if (string.IsNullOrWhiteSpace(txtConfirmPassword))
                {
                    validInput = false;
                    ViewData[Constants.OPERATIONALMESSAGE] = Utils.getErrorMessage("Input field required", "Please confirm your password");
                }
                if (string.IsNullOrWhiteSpace(txtFirstName))
                {
                    validInput = false;
                    ViewData[Constants.OPERATIONALMESSAGE] = Utils.getErrorMessage("Input field required", "Please enter first name");
                }
                if (string.IsNullOrWhiteSpace(txtLastName))
                {
                    validInput = false;
                    ViewData[Constants.OPERATIONALMESSAGE] = Utils.getErrorMessage("Input field required", "Please enter last name");
                }
                //my own
                if (txtDay.Equals("0"))
                {
                    validInput = false;
                    ViewData[Constants.OPERATIONALMESSAGE] = Utils.getErrorMessage("Input field required", "Please select day of birth");
                }
                if (txtMonth.Equals("0"))
                {
                    validInput = false;
                    ViewData[Constants.OPERATIONALMESSAGE] = Utils.getErrorMessage("Input field required", "Please select month of birth");
                }
                if (txtYear.Equals("0"))
                {
                    validInput = false;
                    ViewData[Constants.OPERATIONALMESSAGE] = Utils.getErrorMessage("Input field required", "Please select year of birth");
                }
                if (string.IsNullOrWhiteSpace(radGender))
                {
                    validInput = false;
                    ViewData[Constants.OPERATIONALMESSAGE] = Utils.getErrorMessage("Input field required", "Please select gender");
                }
                //limit

                if (!string.IsNullOrWhiteSpace(txtPassword) && !string.IsNullOrWhiteSpace(txtConfirmPassword))
                {
                    if (!txtPassword.Trim().Equals(txtConfirmPassword.Trim()))
                    {
                        validInput = false;
                        ViewData[Constants.OPERATIONALMESSAGE] = Utils.getErrorMessage("Incorrect password", "Password and confirm password does not match.");
                    }
                }

                if (!string.IsNullOrWhiteSpace(txtCaptchaCode))
                {
                    if (!txtCaptchaCode.Trim().Equals(new SecurityManager().DecodeString(Session["CaptchaCode"].ToString())))
                    {
                        validInput = false;
                        ViewData[Constants.OPERATIONALMESSAGE] = Utils.getErrorMessage("Invalid security code", "Please enter valid security code");
                    }
                }

                if (validInput == false)
                {
                    Session["CaptchaCode"] = Utils.getCaptchaCode();
                    return View("Index");
                }
                else
                {
                    User userObj = new User();
                    userObj.UserRoleId = Convert.ToInt32(UserRolesType.RegisteredUser);
                    userObj.UserFirstName = txtFirstName;
                    userObj.UserLastName = txtLastName;
                    userObj.UserLoginName = txtLoginName;
                    userObj.Contact_Email = txtEmail;
                    userObj.UserPassword = txtPassword.Trim();
                    userObj.UserContactNumber = txtContactNumber;

                    userObj.Gender = radGender;
                    userObj.DOB = Convert.ToDateTime(txtDay + "/" + txtMonth + "/" + txtYear).Date;
                    userObj.Is_ShopCreated= false;
                    userObj.Created_On = DateTime.UtcNow;
                    userObj.Last_Updated_On = DateTime.UtcNow;
                    userObj.UserStatus = Convert.ToInt16(UserStatusType.InActive);

                    userObj.ProfilePhoto = "BlankImage.jpg";

                    long UserId = new User().CreateUser(userObj);
                    if (UserId <= 0)
                    {
                        validInput = false;
                        ViewData[Constants.OPERATIONALMESSAGE] = Utils.getErrorMessage("Error", "Error occured during process Please try again");
                    }
                    else
                    {

                        if (UserId > 0)
                        {
                            string UserIdEncrypted = new SecurityManager().EncodeString(UserId.ToString());
                            string linkUrl = Utils.getSiteUrl() + "/Register/ActivateMe?mySite=" + UserIdEncrypted;

                            string emailMessage = "<div><b>Your User account created successfully</b></div>";
                            emailMessage = emailMessage + "<div style='padding-top:10px'>Your account is not active for the time being. Click the link below to activate your account</div>";
                            emailMessage = emailMessage + "<div><a href='" + linkUrl + "'>" + linkUrl + "</a></div>";

                            string emailHtml = Utils.GetEmailTemplate(txtFirstName + " " + txtLastName, emailMessage);

                            new EmailManager().SendEmail(txtEmail, SmtpUserName, "Account Activation Link", emailHtml);

                            return RedirectToRoute(new RouteValueDictionary(new { controller = "Register", action = "UserRegistered", webId = UserIdEncrypted }));
                        }
                        else
                        {
                            validInput = false;
                            ViewData[Constants.OPERATIONALMESSAGE] = Utils.getErrorMessage("Error", "Error occured during process Please try again");
                        }

                    }
                }
            }
            catch (Exception)
            {
            }
            Session["CaptchaCode"] = Utils.getCaptchaCode();
            return View("Index");
        }
Ejemplo n.º 10
0
        public ActionResult Index(string RecDelOperation, string RecSaveOperation, string Id)
        {
            ViewData[Constants.MENU_PARENT] = Constants.MENU_MANAGE_PICTURES;
            ViewData[Constants.MENU] = Constants.EDIT_PICTURES;

            ViewBag.TitleDes = "Free shop advertisement";
            try
            {

                if (!String.IsNullOrEmpty(RecDelOperation))
                {
                    ViewData[Constants.OPERATIONALMESSAGE] = Utils.getSuccessMessage("Success", "Record deleted successfully.");
                }
                if (!String.IsNullOrEmpty(RecSaveOperation))
                {
                    ViewData[Constants.OPERATIONALMESSAGE] = Utils.getSuccessMessage("Success", "Record saved successfully.");
                }

                if (!string.IsNullOrWhiteSpace(Id))
                {
                    string User_id = new SecurityManager().DecodeString(Id);
                    User user = new User().GetUser(Convert.ToInt64(User_id));
                    if (user != null)
                    {
                        user.Shop_Image_List = new Shop_Image().GetShopImagesList(user.UserId);
                        user.UserEntity = new User().GetUser(user.UserId);
                    }
                    ViewData.Model = user;
                    user = null;
                }
                else
                {
                    Int64 user_id = new UserSession().getUserSession().UserId;
                    User user = new User().GetUser(user_id);
                    if (user != null)
                    {
                        user.Shop_Image_List = new Shop_Image().GetShopImagesList(user.UserId);
                        user.UserEntity = new User().GetUser(user.UserId);
                    }
                    ViewData.Model = user;
                    user = null;
                }
                return View();
            }
            catch (Exception)
            {
            }
            return null;
        }
Ejemplo n.º 11
0
        public ActionResult DeleteShopImage(string Shop_Image_Id)
        {
            try
            {
                string imageId = new SecurityManager().DecodeString(Shop_Image_Id);

                Shop_Image shopImage = new Shop_Image().GetShopImage(Convert.ToInt64(imageId));
                if (shopImage != null)
                {
                    Int64 UserId = shopImage.User_Id;
                    deleteUploadedImage(shopImage.Image_Path, UserId);
                    new Shop_Image().DeleteShopImage(shopImage.Shop_Image_Id);

                    string Enc_UserId = new SecurityManager().EncodeString(Convert.ToString(UserId));
                    return RedirectToRoute(new RouteValueDictionary(new { controller = "ShopImages", action = "Index", Id = Enc_UserId }));

                }

            }
            catch (Exception)
            {
            }
            return RedirectToRoute(new RouteValueDictionary(new { controller = "Home", action = "Dashboard" }));
        }
Ejemplo n.º 12
0
 public static string getCaptchaCode()
 {
     string captchaCode = Guid.NewGuid().ToString();
     if (captchaCode.Length > 6)
     {
         captchaCode = Guid.NewGuid().ToString().Substring(1, 6);
     }
     captchaCode = new SecurityManager().EncodeString(captchaCode);
     return captchaCode;
 }