示例#1
0
        public int AddUpdateStudentInvoice(StudentInvoice student)
        {
            if (student.ID == 0)
            {
                student.CreatedDate = DateTime.Now;
                HIQAdminContext.StudentInvoices.Add(student);
            }
            else
            {
                var invoice = HIQAdminContext.StudentInvoices.FirstOrDefault(x => x.ID == student.ID);
                if (invoice != null)
                {
                    invoice.Name          = student.Name;
                    invoice.PaymentMode   = student.PaymentMode;
                    invoice.PaymentStatus = student.PaymentStatus;
                    invoice.Mobile        = student.Mobile;
                    invoice.Status        = student.Status;
                    invoice.SubTotal      = student.SubTotal;
                    invoice.ModifiedDate  = DateTime.Now;
                    HIQAdminContext.Entry(invoice).State = EntityState.Modified;
                }
            }

            return(HIQAdminContext.SaveChanges() > 0 ? student.UserID : 0);
        }
示例#2
0
        public int RegisterUser(UserMaster user)
        {
            if (user.UserID == 0)
            {
                user.IsActive      = true;
                user.AccountStatus = 1;
                user.Password      = string.IsNullOrEmpty(user.Password) ? "123456" : user.Password;
                user.CreatedDate   = DateTime.Now;
                HIQAdminContext.UserMasters.Add(user);
                return(HIQAdminContext.SaveChanges() > 0 ? user.UserID : 0);
            }

            UserMaster User = HIQAdminContext.UserMasters.FirstOrDefault(x => x.UserID == user.UserID);

            User.ModifiedBy   = user.ModifiedBy;
            User.ModifiedDate = DateTime.Now;
            User.Password     = user.Password;
            User.Address      = user.Address;
            User.City         = user.City;
            User.Mobile       = user.Mobile;
            User.Phone        = user.Phone;
            User.Pin          = user.Pin;
            User.Image        = user.Image;
            User.IsDeleted    = user.IsDeleted;

            HIQAdminContext.Entry(User).State = EntityState.Modified;
            return(HIQAdminContext.SaveChanges() > 0 ? user.UserID : 0);
        }
示例#3
0
        public int AddUpdateBlog(BlogMaster blog)
        {
            blog.CreatedDate = DateTime.Now;
            HIQAdminContext.BlogMasters.Add(blog);
            HIQAdminContext.SaveChanges();

            return(blog.ID);
        }
示例#4
0
        /// <summary>
        /// save OTP (One Time Password) to database
        /// </summary>
        /// <param name="otp"> Object of OTP</param>
        /// <returns>returns true when data is saved</returns>
        public bool SaveOTP(OTPMaster otp)
        {
            bool IsSuccess = false;

            // In case from Generating OTP from Automatic redirect to Change Password because of not complex password multiple OTPs can be generated
            // Use this validation to restrict user to generate multiple OTPs
            if (ValidateUser(otp.UserID, AspectEnums.UserValidationType.LastAttemptDuration))
            {
                HIQAdminContext.Entry(otp).State = EntityState.Added;
                IsSuccess = HIQAdminContext.SaveChanges() > 0;
            }
            return(IsSuccess);
        }
示例#5
0
        public int AddUserRole(UserMaster user, bool isAdmin)
        {
            int roleId = user.IsEmployee ? (int)AspectEnums.RoleType.Employee : user.IsCustomer ? (int)AspectEnums.RoleType.Customer : (int)AspectEnums.RoleType.Student;

            HIQAdminContext.UserRoles.Add(new UserRole {
                UserID = user.UserID, RoleID = roleId, CreatedBy = user.CreatedBy, CreatedDate = DateTime.Now, IsActive = true
            });
            if (isAdmin)
            {
                HIQAdminContext.UserRoles.Add(new UserRole {
                    UserID = user.UserID, RoleID = (int)AspectEnums.RoleType.Admin, CreatedBy = user.CreatedBy, CreatedDate = DateTime.Now, IsActive = true
                });
            }
            return(HIQAdminContext.SaveChanges());
        }
示例#6
0
        public int SubmitNewStudent(UserMaster student)
        {
            student.IsActive      = true;
            student.AccountStatus = 1;
            student.Password      = "******";
            student.CreatedDate   = DateTime.Now;
            HIQAdminContext.UserMasters.Add(student);
            var result = HIQAdminContext.SaveChanges() > 0 ? student.UserID : 0;

            if (result > 0 && student.IsEmployee)
            {
                HIQAdminContext.UserRoles.Add(new UserRole {
                    UserID = student.UserID, RoleID = (int)AspectEnums.RoleType.Admin, CreatedBy = student.CreatedBy, CreatedDate = DateTime.Now, IsActive = true
                });
                HIQAdminContext.SaveChanges();
            }
            return(result);
        }
示例#7
0
        /// <summary>
        /// Change password of User
        /// </summary>
        /// <param name="GUID"> uniqe string </param>
        /// <param name="Password">password entered by user</param>
        /// <returns></returns>
        public bool ChangePassword(string GUID, string Password)
        {
            int       OTPExirationHrs = Convert.ToInt32(AppUtil.GetAppSettings(AspectEnums.ConfigKeys.OTPExirationHrs));
            DateTime  StartTime       = DateTime.Now.Subtract(new TimeSpan(OTPExirationHrs, 0, 0));
            DateTime  EndTime         = DateTime.Now;
            OTPMaster objOTP          = HIQAdminContext.OTPMasters.FirstOrDefault(k => k.CreatedDate >= StartTime && k.CreatedDate <= EndTime && k.GUID == GUID);

            if (objOTP != null)
            {
                UserMaster user = HIQAdminContext.UserMasters.FirstOrDefault(k => k.UserID == objOTP.UserID && !k.IsDeleted);
                user.Password = EncryptionEngine.EncryptString(Password);
                HIQAdminContext.Entry(user).State = EntityState.Modified;
                //Delete all previous OTPs
                foreach (var o in HIQAdminContext.OTPMasters.Where(k => k.UserID == user.UserID))
                {
                    HIQAdminContext.OTPMasters.Remove(o);
                }

                return(HIQAdminContext.SaveChanges() > 0);
            }

            return(false);
        }
示例#8
0
        /// <summary>
        /// Authenticate OTP (One Time Password) entered by user
        /// </summary>
        /// <param name="userid">Userid</param>
        /// <param name="otp">One Time Password</param>
        /// <returns>reurns true if user have enterered latest OTP</returns>
        public bool AuthenticateOTP(long userid, string otp, out string GuidString, out int MaxAttempts)
        {
            OTPMaster ObjOTP = HIQAdminContext.OTPMasters.OrderByDescending(k => k.CreatedDate).FirstOrDefault(k => k.UserID == userid);

            GuidString  = "";
            MaxAttempts = 0;
            if (ObjOTP != null)
            {
                MaxAttempts = ObjOTP.Attempts.Value;
                if (ObjOTP.OTP == otp)
                {
                    GuidString = ObjOTP.GUID;
                    return(true);
                }

                ObjOTP.Attempts = ++MaxAttempts;
                HIQAdminContext.Entry(ObjOTP).State = EntityState.Modified;
                HIQAdminContext.SaveChanges(); // TBD
            }

            //}

            return(false);
        }