/// <summary>
        /// method is used for validate application users
        /// </summary>
        /// <param name="Logininfo"></param>
        /// <returns></returns>
        public object GetLoginUser(LoginUserModel Logininfo)
        {
            APIResponse       _response        = new APIResponse();
            LoggedInUserModel lgAppUserDetails = new LoggedInUserModel();
            object            objLgAppUserDetails;

            try
            {
                using (dbcontext = new AlertBackEntities())
                {
                    Logininfo.UserName = Logininfo.UserName.ToLower();
                    tblApplicationUser lgDetail = dbcontext.tblApplicationUsers.FirstOrDefault(x => x.UserName.ToLower() == Logininfo.UserName && x.IsDeleted == false);

                    if (lgDetail != null)
                    {
                        if (lgDetail.Password == Logininfo.Password)
                        {
                            lgAppUserDetails.ApplicationUserId = lgDetail.ApplicationUserId;
                            lgAppUserDetails.UserIdentityKey   = lgDetail.UserIdentityKey;
                            lgAppUserDetails.success           = true;
                            lgAppUserDetails.ErrorMessage      = "User Authenticated!!";
                            lgAppUserDetails.Name        = lgDetail.Name == null ? "" : lgDetail.Name;
                            lgAppUserDetails.EmailId     = lgDetail.EmailId;
                            lgAppUserDetails.MobileNo    = lgDetail.MobileNo;
                            lgAppUserDetails.Gender      = lgDetail.Gender;
                            lgAppUserDetails.DateOfBirth = lgDetail.DateOfBirth;
                            lgAppUserDetails.Address     = lgDetail.Address;
                            lgAppUserDetails.FatherName  = lgDetail.tblMember == null ? "" : lgDetail.tblMember.FatherName;
                            lgAppUserDetails.MotherName  = lgDetail.tblMember == null ? "" : lgDetail.tblMember.MotherName;
                            lgAppUserDetails.UserName    = lgDetail.UserName;

                            _response.Message  = "User Authenticated!!";
                            _response.IsSucess = true;
                        }
                        else
                        {
                            lgAppUserDetails.ErrorMessage = "Invalid password!!";
                            _response.Message             = "Invalid password!!";
                            _response.IsSucess            = false;
                        }
                    }
                    else
                    {
                        lgAppUserDetails.ErrorMessage = "Invalid username!!";
                        _response.Message             = "Invalid username!!";
                        _response.IsSucess            = false;
                    }
                }
            }
            catch (Exception ex)
            {
                lgAppUserDetails              = null;
                objLgAppUserDetails           = null;
                dbcontext                     = null;
                lgAppUserDetails.ErrorMessage = ex.Message.ToString();
            }
            objLgAppUserDetails = lgAppUserDetails;
            return(objLgAppUserDetails);
        }
        public object GetMyCurrentPosition(TrackMyPositionCustomModel model)
        {
            List <TrackMyPositionCustomModel> PositionListModel = new List <TrackMyPositionCustomModel>();

            using (response = new Response())
            {
                using (dbcontext = new AlertBackEntities())
                {
                    try
                    {
                        response.success = true;
                        var rs = dbcontext.tblTrackMyPositions.Where(x => x.IsDeleted == false &&
                                                                     x.MemberId == model.MemberId
                                                                     )
                                 .Select(x => new TrackMyPositionCustomModel
                        {
                            Id          = x.Id,
                            MemberId    = x.MemberId,
                            MemberName  = x.tblMember != null ? x.tblMember.Name : "",
                            Title       = x.Title,
                            Description = x.Description,
                            Image       = x.Image,
                            DDate       = x.DDate,
                            Longitude   = x.Longitude,
                            Latitude    = x.Latitude,
                            Place       = x.Place,

                            IsActive     = x.IsActive,
                            IsDeleted    = x.IsDeleted,
                            CreatedBy    = x.CreatedBy,
                            CreatedDate  = x.CreatedDate,
                            ModifiedBy   = x.ModifiedBy,
                            ModifiedDate = x.ModifiedDate
                        }).OrderByDescending(x => x.Id).FirstOrDefault();

                        return(rs);
                    }
                    catch (Exception ex)
                    {
                        response.success = false;
                        response.message = ex.Message;
                        return(response);
                    }
                }
            }
        }
        public OperationStatus SaveMyCurrentPosition(TrackMyPositionCustomModel model)
        {
            OperationStatus status = OperationStatus.Error;

            try
            {
                using (dbcontext = new AlertBackEntities())
                {
                    if (model.Id == 0)
                    {
                        tblTrackMyPosition _addMyPosition = new tblTrackMyPosition
                        {
                            MemberId    = model.MemberId,
                            Title       = model.Title,
                            Description = model.Description,
                            Image       = model.Image,
                            DDate       = model.DDate,
                            Longitude   = model.Longitude,
                            Latitude    = model.Latitude,
                            Place       = model.Place,

                            IsActive     = true,
                            IsDeleted    = false,
                            CreatedDate  = DateTime.Now,
                            CreatedBy    = model.CreatedBy,
                            ModifiedDate = DateTime.Now,
                            ModifiedBy   = model.ModifiedBy
                        };
                        dbcontext.tblTrackMyPositions.Add(_addMyPosition);
                        dbcontext.SaveChanges();
                        status = OperationStatus.Success;
                    }
                }
            }
            catch (Exception ex)
            {
                dbcontext.Dispose();
                status = OperationStatus.Exception;
                throw ex;
            }

            return(status);
        }
        public object GetApplicationMemberList(MemberCustomModel objMemberModel)
        {
            IList <MemberCustomModel> MemberListModel = new List <MemberCustomModel>();

            using (response = new Response())
            {
                using (dbcontext = new AlertBackEntities())
                {
                    try
                    {
                        response.success = true;
                        MemberListModel  = dbcontext.tblMembers.Where(x => x.IsDeleted == false)
                                           .Select(x => new MemberCustomModel
                        {
                            MemberId     = x.MemberId,
                            Name         = x.Name,
                            EmailId      = x.EmailId,
                            MobileNo     = x.MobileNo,
                            MotherName   = x.MotherName,
                            FatherName   = x.FatherName,
                            Address      = x.Address,
                            DateOfBirth  = x.DateOfBirth,
                            Gender       = x.Gender,
                            Image        = x.Image,
                            IsActive     = x.IsActive,
                            IsDeleted    = x.IsDeleted,
                            CreatedBy    = x.CreatedBy,
                            CreatedDate  = x.CreatedDate,
                            ModifyBy     = x.ModifyBy,
                            ModifiedDate = x.ModifiedDate,
                        }).OrderByDescending(x => x.MemberId).ToList();

                        return(MemberListModel);
                    }
                    catch (Exception ex)
                    {
                        response.success = false;
                        response.message = ex.Message;
                        return(response);
                    }
                }
            }
        }
        /// <summary>
        /// This method is used to save new members
        /// </summary>
        /// <returns></returns>
        public OperationStatus SaveApplicationUser(ApplicationUserModel applicationUserModel)
        {
            OperationStatus status = OperationStatus.Error;

            using (TransactionScope ts = new TransactionScope())
            {
                try
                {
                    using (dbcontext = new AlertBackEntities())
                    {
                        if (applicationUserModel.ApplicationUserId == 0)
                        {
                            var rs = dbcontext.tblApplicationUsers.FirstOrDefault(x => x.UserName == applicationUserModel.UserName && x.IsDeleted == false);
                            if (rs == null)
                            {
                                tblMember _addMember = new tblMember
                                {
                                    Name        = applicationUserModel.Name,
                                    EmailId     = applicationUserModel.EmailId,
                                    MobileNo    = applicationUserModel.MobileNo,
                                    Gender      = applicationUserModel.Gender,
                                    DateOfBirth = applicationUserModel.DateOfBirth,
                                    Address     = applicationUserModel.Address,
                                    FatherName  = applicationUserModel.FatherName,
                                    MotherName  = applicationUserModel.MotherName,

                                    IsActive     = true,
                                    IsDeleted    = false,
                                    CreatedDate  = DateTime.Now,
                                    CreatedBy    = applicationUserModel.CreatedBy,
                                    ModifiedDate = DateTime.Now,
                                    ModifyBy     = applicationUserModel.ModifyBy,
                                };
                                dbcontext.tblMembers.Add(_addMember);
                                dbcontext.SaveChanges();
                                int userid = _addMember.MemberId;

                                tblApplicationUser _applicationUserinfo = new tblApplicationUser
                                {
                                    Name        = applicationUserModel.Name,
                                    EmailId     = applicationUserModel.EmailId,
                                    MobileNo    = applicationUserModel.MobileNo,
                                    Gender      = applicationUserModel.Gender,
                                    DateOfBirth = applicationUserModel.DateOfBirth,
                                    Address     = applicationUserModel.Address,

                                    UserIdentityKey = userid,
                                    UserName        = applicationUserModel.UserName,
                                    Password        = applicationUserModel.Password,

                                    IsActive     = true,
                                    IsDeleted    = false,
                                    CreatedDate  = DateTime.Now,
                                    CreatedBy    = applicationUserModel.CreatedBy,
                                    ModifiedDate = DateTime.Now,
                                    ModifyBy     = applicationUserModel.ModifyBy,
                                };

                                dbcontext.tblApplicationUsers.Add(_applicationUserinfo);
                                dbcontext.SaveChanges();

                                status = OperationStatus.Success;
                                ts.Complete();
                            }
                            else
                            {
                                status = OperationStatus.Duplicate;
                                //ts.Dispose();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    dbcontext.Dispose();
                    status = OperationStatus.Exception;
                    ts.Dispose();
                    throw ex;
                }
            }
            return(status);
        }