public ActionResult CheckUserAvailability(string txtLoginName)
        {
            try
            {

                if (!string.IsNullOrEmpty(txtLoginName))
                {
                    string loginName = new UserSession().getUserSession().UserLoginName;

                    Boolean retResult = new User().CheckUserAvailablity(txtLoginName.Trim());
                    if (loginName == txtLoginName)
                    {
                        Response.Write("2");
                    }
                    else
                    {
                        if (retResult == true)
                        {
                            Response.Write("1");
                        }
                        else
                        {
                            Response.Write("0");
                        }
                    }
                }
                else
                {
                    Response.Write("2");
                }
            }
            catch (Exception)
            {
            }
            return null;
        }
        public ActionResult ManageGroups(string RecCreateOperation, string RecUpdateOperation)
        {
            ViewData[Constants.MENU_PARENT] = Constants.MENU_MANAGE_GROUPS;
            ViewData[Constants.MENU] = Constants.MANAGE_GROUPS;
            ViewBag.TitleDes = "Free shop advertisement";
            if (!String.IsNullOrEmpty(RecCreateOperation))
            {
                ViewData[Constants.OPERATIONALMESSAGE] = Utils.getSuccessMessage("Success", "Group Created successfully.");
            }
            if (!String.IsNullOrWhiteSpace(RecUpdateOperation))
            {
                ViewData[Constants.OPERATIONALMESSAGE] = Utils.getSuccessMessage("Success", "Group setting changed successfully.");
            }
            List<Group> g = new List<Group>();
            Int64 userId = new ShopOnline.Filters.UserSession().getUserSession().UserId;
            g = new Group().getGroups(Convert.ToInt64(userId));

            ViewData.Model = g;
            return View();
        }
        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");
        }
 public ActionResult ShopRegister()
 {
     ViewBag.TitleDes = "Free shop advertisement";
     if (new UserSession().EverLogin_User() == false)
     {
         return View();
     }
     else
     {
         Int64 userid = new UserSession().getUserSession().UserId;
         User user=new User().GetUser(userid);
         ViewData.Model = user;
         return RedirectToRoute(new RouteValueDictionary(new { controller = "ShopImages", action = "Index", Id = user.UserId }));
     }
 }
        public string uploadShopProfileImage(HttpPostedFileBase file)
        {
            try
            {
                string fileName = "";
                string retFileName = "";
                if (file != null)
                {
                    fileName = new UserSession().getUserSession().UserId + "_" + DateTime.UtcNow.ToString();
                    fileName = fileName.Replace(" ", "");
                    fileName = fileName.Replace("/", "_");
                    fileName = fileName.Replace(":", "_");
                    fileName = fileName + Path.GetFileName(file.FileName);
                    retFileName = fileName;

                    string userFolder = Server.MapPath("../" + Constants.UPLOADED_IMAGES_SHOP);
                    if (!Directory.Exists(userFolder))
                    {
                        Directory.CreateDirectory(userFolder);
                    }

                    string filePath = userFolder + "\\" + fileName;
                    file.SaveAs(filePath);

                    file.InputStream.Flush();
                    file.InputStream.Close();
                    file.InputStream.Dispose();

                    GenerateShopThumbNail(retFileName);
                    //GenerateShopThumbNail_ShopHome(retFileName);
                }
                return retFileName;
            }
            catch (Exception)
            {
                return string.Empty;
            }
        }
        public string uploadProfileImage(HttpPostedFileBase file, Int64 UserId)
        {
            try
            {
                string fileName = "";
                string retFileName = "";
                if (file != null)
                {
                    fileName = new UserSession().getUserSession().UserId + "_" + UserId + "_" + DateTime.UtcNow.ToString();
                    fileName = fileName.Replace(" ", "");
                    fileName = fileName.Replace("/", "_");
                    fileName = fileName.Replace(":", "_");
                    fileName = fileName + Path.GetFileName(file.FileName);
                    retFileName = fileName;

                    string userFolder = Server.MapPath("../" + Constants.UPLOADED_IMAGES_SHOP + "/" + UserId);
                    if (!Directory.Exists(userFolder))
                    {
                        Directory.CreateDirectory(userFolder);
                    }

                    string filePath = userFolder + "\\" + fileName;
                    file.SaveAs(filePath);
                    GenerateThumbNailForSlider(retFileName, UserId);
                }
                return retFileName;
            }
            catch (Exception)
            {
                return string.Empty;
            }
        }
        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;
        }
        public ActionResult UpdateUser(string id)
        {
            ViewData[Constants.MENU_PARENT] = Constants.MENU_MANAGE_PROFILE;
            ViewData[Constants.MENU] = Constants.EDIT_USER_PROFILE;

            ViewBag.TitleDes = "Free shop advertisement";
            Int64 userid = new UserSession().getUserSession().UserId;
            User user = new User().GetUser(userid);
            ViewData.Model = user;

            //ViewData["txtLoginName"] = user.UserLoginName;
            //ViewData["txtEmail"] = user.Contact_Email;
            //ViewData["txtFirstName"] = user.UserFirstName;
            //ViewData["txtLastName"] = user.UserLastName;
            //ViewData[" txtContactNumber"] = user.UserContactNumber;
            //ViewData["radGender"] = user.Gender;
            //string s = Convert.ToString(user.DOB);
            //string[] values = s.Split('/', ' ');
            //int ii = values.Length;
            //for (int i = 0; i < values.Length; i++)
            //{
            //    values[i] = values[i].Trim();
            //    if (i == 0)
            //    {
            //        string day = values[i].Trim();
            //        ViewData["txtDay"] = values[i].Trim();
            //    }
            //    else if (i == 1)
            //    {
            //        string month = values[i].Trim();
            //        ViewData["txtMonth"] = values[i].Trim();
            //    }
            //    else if (i == 2)
            //    {
            //        string year = values[i].Trim();
            //        ViewData["txtYear"] = values[i].Trim();
            //    }
            //}
            return View();
        }
        public ActionResult UpdateShop(string id)
        {
            ViewBag.TitleDes = "Free shop advertisement";

            ViewData[Constants.MENU_PARENT] = Constants.MENU_MANAGE_PROFILE;
            ViewData[Constants.MENU] = Constants.EDIT_SHOP_PROFILE;

            Int64 userid = new UserSession().getUserSession().UserId;
            User user = new User().GetUser(userid);
            ViewData.Model = user;
            return View();
        }