public ActionResult Create(RegistrationViewModel objEntity)
        {
            RegistrationRepository objRegistrationRepository = new RegistrationRepository();

            if (ModelState.IsValid)
            {

                objEntity.Status = StatusFlags.Active.GetHashCode();
                objEntity.UserTypeId = UserTypes.User.GetHashCode();

                objRegistrationRepository.Insert(objEntity);

                if (objEntity.Result == ResultFlags.Success.GetHashCode())
                {
                    this.Flash("success", "Registration created successfully ");

                    //return RedirectToAction("Index");
                    return RedirectToAction("Login", "User");

                }
                else if (objEntity.Result == ResultFlags.Failure.GetHashCode())
                {
                    this.Flash("error", "Failed to create account");

                    return RedirectToAction("Index");
                }
                else if (objEntity.Result == ResultFlags.Duplicate.GetHashCode())
                {
                    this.Flash("warning", "It already exist");

                }
            }

            return View(objEntity);
        }
        //
        // GET: /Employee1/Delete/5
        //  [UserAuthorized]
        public ActionResult Delete(int id)
        {
            var objRegistrationRepository = new RegistrationRepository();
            int result = 0;
            result = objRegistrationRepository.Delete(RegistrationFlags.DeleteByID.GetHashCode(), new RegistrationViewModel()
            {
                RegistrationId = id
            });
            if (result == ResultFlags.Success.GetHashCode())
            {
                this.Flash("success", "Account deleted successfully ");

                return RedirectToAction("Index");
            }
            else if (result == ResultFlags.Failure.GetHashCode())
            {
                this.Flash("error", "Failed to delete your account");

                return RedirectToAction("Index");
            }
            return RedirectToAction("Index");
        }
        public ActionResult ProfileEdit(int id, RegistrationUpdateViewModel objUpdateEntity)
        {
            var objRegistrationRepository = new RegistrationRepository();
            string fileName = string.Empty;
            string oldFileName = string.Empty;

            if (ModelState.IsValid)
            {
                #region FileUpload

                if (objUpdateEntity.UploadPhoto != null)
                {
                    fileName = Guid.NewGuid().ToString() + Path.GetExtension(objUpdateEntity.UploadPhoto.FileName);
                    oldFileName = objUpdateEntity.PhotoName;
                    objUpdateEntity.PhotoName = fileName;
                }

                #endregion
                objUpdateEntity.FirstName = objUpdateEntity.FirstName.Trim();
                objUpdateEntity.LastName = objUpdateEntity.LastName.Trim();
                objUpdateEntity.PhotoName = objUpdateEntity.PhotoName;
                objUpdateEntity.DateOfBirth = objUpdateEntity.DateOfBirth;
                objUpdateEntity.Location = objUpdateEntity.Location.Trim();
                objUpdateEntity.MobileNumber = objUpdateEntity.MobileNumber.Trim();
                objUpdateEntity.RegistrationId = id;

                var objEntity = new RegistrationViewModel()
                {
                    RegistrationId = objUpdateEntity.RegistrationId,
                    UserId = objUpdateEntity.UserId,
                    FirstName = objUpdateEntity.FirstName,
                    LastName = objUpdateEntity.LastName,
                    PhotoName = objUpdateEntity.PhotoName,

                    DateOfBirth = objUpdateEntity.DateOfBirth,
                    Gender = objUpdateEntity.Gender,

                    Location = objUpdateEntity.Location,
                    MobileNumber = objUpdateEntity.MobileNumber
                };

                objEntity = objRegistrationRepository.Update(RegistrationFlags.UpdateByID.GetHashCode(), objEntity);

                if (objEntity.Result == ResultFlags.Success.GetHashCode())
                {
                    #region FileUpload
                    //delete old file

                    //file name
                    if (objUpdateEntity.UploadPhoto != null)
                    {
                        if (!string.IsNullOrEmpty(objUpdateEntity.UploadPhoto.FileName))
                        {
                            ApplicationHelpers.DeleteFile(Path.Combine(Server.MapPath(ApplicationConstant.UPLOADED_USER_PHOTO_PATH), oldFileName));
                        }
                        string path = Path.Combine(Server.MapPath(ApplicationConstant.UPLOADED_USER_PHOTO_PATH), fileName);
                        // WebImage.Save()
                        objUpdateEntity.UploadPhoto.SaveAs(path);
                    }

                    #endregion

                    this.Flash("Success", "My Profile updated successfully ");

                    //reload admin profile
                    SessionWrapper.UserAccount = null;
                    AccountRepository objAccountRepository = new AccountRepository();
                    objAccountRepository.SetAccountByUser(objEntity.UserId);

                    return RedirectToAction("Dashboard", "Admin");
                }
                else if (objEntity.Result == ResultFlags.Failure.GetHashCode())
                {
                    this.Flash("Error", "My Profile failed to update");

                }
                else if (objEntity.Result == ResultFlags.Duplicate.GetHashCode())
                {
                    this.Flash("Warning", "It already exist");

                }
            }

            return View(objUpdateEntity);
        }
        public ActionResult ProfileEdit(int id)
        {
            var objRegistrationRepository = new RegistrationRepository();

            var objEntity = new RegistrationViewModel();

            var objUpdateEntity = new RegistrationUpdateViewModel();

            objEntity = objRegistrationRepository.Select(RegistrationFlags.SelectByID.GetHashCode(), new RegistrationViewModel()
            {
                RegistrationId = id
            }).FirstOrDefault();
            if (objEntity == null)
            {
                this.Flash("error", "Failed to edit profile details");

                return RedirectToAction("Dashboard");
            }

            objUpdateEntity.RegistrationId = objEntity.RegistrationId;
            objUpdateEntity.UserId = objEntity.UserId;
            objUpdateEntity.FirstName = objEntity.FirstName;
            objUpdateEntity.LastName = objEntity.LastName;
            objUpdateEntity.PhotoName = objEntity.PhotoName;

            objUpdateEntity.DateOfBirth = objEntity.DateOfBirth;
            objUpdateEntity.Gender = objEntity.Gender;

            objUpdateEntity.Location = objEntity.Location;
            objUpdateEntity.MobileNumber = objEntity.MobileNumber;

            return View(objUpdateEntity);
        }
        public ActionResult MyProfile(int id)
        {
            var objRegistrationRepository = new RegistrationRepository();
            RegistrationViewModel objEntity = null;
            objEntity = objRegistrationRepository.Select(RegistrationFlags.SelectByID.GetHashCode(), new RegistrationViewModel()
            {
                RegistrationId = id
            }).FirstOrDefault();
            if (objEntity == null)
            {
                this.Flash("error", "Failed to show my profile");

                return RedirectToAction("Index");
            }

            return View(objEntity);
        }
        public ActionResult Register(RegistrationViewModel objEntity)
        {
            RegistrationRepository objRegistrationRepository = new RegistrationRepository();
            string fileName = string.Empty;

            if (ModelState.IsValid)
            {
                #region FileUpload

                if (objEntity.UploadPhoto != null)
                {
                    fileName = Guid.NewGuid().ToString() + Path.GetExtension(objEntity.UploadPhoto.FileName);
                    objEntity.PhotoName = fileName;

                }
                else
                {
                    objEntity.PhotoName = string.Empty;
                }

                #endregion

                objEntity.RoleId = (Int16)RoleUserDefinedEnum.User.GetHashCode();

                PasswordHelpers.HashedPassword objHashedPassword = PasswordHelpers.Generate(objEntity.Password);

                objEntity.Password = objHashedPassword.Password;

                objEntity.PasswordSalt = objHashedPassword.Salt;

                objEntity.Status = StatusEnum.Active.GetHashCode();

                objRegistrationRepository.Insert(objEntity);

                if (objEntity.Result == ResultFlags.Success.GetHashCode())
                {
                    this.Flash("success", "Registration created successfully ");

                    #region FileUpload

                    //file name
                    if (objEntity.PhotoName != null)
                    {
                        string path = Path.Combine(Server.MapPath(ApplicationConstant.UPLOADED_USER_PHOTO_PATH), fileName);
                        // WebImage.Save()
                        objEntity.UploadPhoto.SaveAs(path);
                    }

                    #endregion
                    //return RedirectToAction("Index");
                    return RedirectToAction("Login", "User");

                }
                else if (objEntity.Result == ResultFlags.Failure.GetHashCode())
                {
                    this.Flash("Error", "Failed to create account");

                    return RedirectToAction("Index");
                }
                else if (objEntity.Result == ResultFlags.Duplicate.GetHashCode())
                {
                    this.Flash("Warning", "It already exist");

                }
            }

            return View(objEntity);
        }
        // GET: /Employee1/
        //   [UserAuthorized]
        public ActionResult Index()
        {
            var objRegistrationRepository = new RegistrationRepository();
            List<RegistrationViewModel> objEntityList = objRegistrationRepository.Select(RegistrationFlags.SelectAll.GetHashCode(), new RegistrationViewModel()
            {

            });
            if (objEntityList.Count == 0)
            {
                this.Flash("error", "No accounts");

            }
            return View(objEntityList);
        }
        public ActionResult Edit(int id, RegistrationUpdateViewModel objUpdateEntity)
        {
            var objRegistrationRepository = new RegistrationRepository();

            if (ModelState.IsValid)
            {

                objUpdateEntity.Name = objUpdateEntity.Name.Trim();

                objUpdateEntity.City = objUpdateEntity.City.Trim();
                objUpdateEntity.MobileNumber = objUpdateEntity.MobileNumber.Trim();
                objUpdateEntity.RegistrationId = id;

             var objEntity=   new RegistrationViewModel()
                    {
                        RegistrationId = objUpdateEntity.RegistrationId,
                        UserId = objUpdateEntity.UserId,
                        Name = objUpdateEntity.Name,

                        DateOfBirth = objUpdateEntity.DateOfBirth,
                        Gender = objUpdateEntity.Gender,

                        City = objUpdateEntity.City,
                        MobileNumber = objUpdateEntity.MobileNumber
                    };

             objEntity = objRegistrationRepository.Update(RegistrationFlags.UpdateByID.GetHashCode(), objEntity);

             if (objEntity.Result == ResultFlags.Success.GetHashCode())
                {
                    this.Flash("success", "Data updated successfully ");

                    return RedirectToAction("Index");
                }
             else if (objEntity.Result == ResultFlags.Failure.GetHashCode())
                {
                    this.Flash("error", "Account failed to update");

                }
             else if (objEntity.Result == ResultFlags.Duplicate.GetHashCode())
                {
                    this.Flash("warning", "It already exist");

                }
            }

            return View(objUpdateEntity);
        }