Esempio n. 1
0
        public object UpdateUser(ParamRegistration PR)
        {
            try
            {
                tbl_user obj = context.tbl_user.Where(r => r.UserId == PR.UserId).FirstOrDefault();

                if (PR.Password == null)
                {
                    obj.name    = PR.Name;
                    obj.email   = PR.Email;
                    obj.contact = PR.Contact;
                    //obj.password = PR.Password;
                }
                else
                {
                    obj.name     = PR.Name;
                    obj.email    = PR.Email;
                    obj.contact  = PR.Contact;
                    obj.password = CryptIt.Encrypt(PR.Password);
                }
                context.SaveChanges();
                return(new Result()
                {
                    IsSucess = true, ResultData = "User Updated Successfully."
                });
            }
            catch (Exception ex)
            {
                return(new Error()
                {
                    IsError = true, Message = ex.Message
                });
            }
        }
        //SchoolContext db = new SchoolContext();

        public TBLUSERLOGIN GetLoginDetails(ParamLogin userLogin)
        {
            SchoolMainContext db = new ConcreateContext().GetContext(userLogin.UserName, userLogin.Password);


            string passecrypt  = CryptIt.Encrypt(userLogin.Password);
            var    logindetail = db.TBLUSERLOGINs.
                                 Where(r => r.UserName == userLogin.UserName && r.Password == passecrypt && r.STATUS == "ACTIVE")
                                 .FirstOrDefault();

            return(logindetail);
        }
        public bool ValidateUsernamePassword(Int32 USERID, string PASSWORD)
        {
            //SchoolMainContext objSC = new ConcreateContext().GetContext(USERID, PASSWORD);
            GRContext db  = new GRContext();
            string    pwd = CryptIt.Encrypt(PASSWORD);

            var usernamepwd = db.ViewUsers.Where(r => r.UserId == USERID && r.password == pwd && r.Islive == 1).ToList();

            if (usernamepwd.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 4
0
        public object GetUser()
        {
            var name = CryptIt.Decrypt("vPelNrzLabeGOYF6LMYvZA==");

            try
            {
                UserCredentialModel userCredentialModel = new UserCredentialModel()
                {
                    UserName = "******"
                };
                return(userCredentialModel);
            }
            catch (Exception e)
            {
                return(new Error()
                {
                    IsError = true, Message = e.Message
                });
            }
        }
        public object IsValidUser(UserCredentialModel userCredentialModel)
        {
            var password = CryptIt.Encrypt(userCredentialModel.Password);
            var user     = db.tbl_user.FirstOrDefault(r => r.email == userCredentialModel.UserName &&
                                                      r.password == password);

            if (user == null)
            {
                return(new Error()
                {
                    IsError = true, Message = "Incorrect User Or Password.."
                });
            }
            else
            {
                //user.code = Convert.ToInt32(HttpContext.Current.Session["Code"]);
                return(new Result()
                {
                    IsSucess = true, ResultData = user
                });
            }
        }
        public object IsValidUser(User user)
        {
            var Password = CryptIt.Encrypt(user.Password);
            var data     = db.TblUserLogins.FirstOrDefault(r => r.UserName == user.UserName &&
                                                           r.Password == Password);

            if (data == null)
            {
                return(new Error()
                {
                    IsError = true, Message = "Incorrect User Or Password.."
                });
            }
            else
            {
                //user.code = Convert.ToInt32(HttpContext.Current.Session["Code"]);
                return(new Result()
                {
                    IsSucess = true, ResultData = user
                });
            }
        }
Esempio n. 7
0
        public object SaveMember([FromBody] MemberParameter obj)
        {
            GRContext db       = new GRContext();
            var       usercode = db.tbl_member.Where(r => r.code == obj.Code).FirstOrDefault();

            if (usercode != null)
            {
                return(new Error()
                {
                    IsError = true, Message = "User Code Already Exists."
                });
            }


            tbl_user objuser = new tbl_user();

            objuser.name         = obj.Name.ToString();
            objuser.UserId       = Convert.ToInt32(obj.UserId);
            objuser.code         = obj.Code;
            objuser.type         = "Member";
            objuser.gender       = obj.Gender.ToString();
            objuser.email        = obj.EmailId.ToString();
            objuser.contact      = Convert.ToInt64(obj.MobileNo);
            objuser.password     = CryptIt.Encrypt(obj.Password);
            objuser.status       = 1;
            objuser.Islive       = 0;
            objuser.Display      = 1;
            objuser.created_date = DateTime.Now;

            db.tbl_user.Add(objuser);

            try
            {
                db.SaveChanges();
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                Exception raise = dbEx;
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        string message = string.Format("{0}:{1}",
                                                       validationErrors.Entry.Entity.ToString(),
                                                       validationError.ErrorMessage);
                        // raise a new exception nesting
                        // the current instance as InnerException
                        raise = new InvalidOperationException(message, raise);
                    }
                }
                throw raise;
            }
            tbl_member objmember = new tbl_member();
            tbl_user   omember   = db.tbl_user.Where(r => r.code == obj.Code).FirstOrDefault();

            objmember.UserId      = omember.UserId;
            objmember.code        = Convert.ToInt32(obj.Code);
            objmember.designation = obj.Designation.ToString();
            if (obj.GriType != null)
            {
                objmember.griType = obj.GriType.ToString();
            }

            objmember.Display      = 1;
            objmember.created_date = DateTime.Now;
            db.tbl_member.Add(objmember);
            db.SaveChanges();
            if (obj.GriType != null)
            {
                tbl_grievance_list list = db.tbl_grievance_list.Where(r => r.grivance_name == objmember.griType).FirstOrDefault();
                list.Isalloted = 1;
                db.SaveChanges();
            }
            return(new Result
            {
                IsSucess = true,
                ResultData = "Member Created!"
            });
        }
Esempio n. 8
0
        public object SaveRegistration(ParamRegistration PR)
        {
            try
            {
                var usercode = db.tbl_user.Where(r => r.code == PR.code).FirstOrDefault();
                if (usercode != null)
                {
                    return(new Error()
                    {
                        IsError = true, Message = "User Code Already Exists."
                    });
                }
                tbl_user objuser = new tbl_user();

                objuser.name    = PR.Name;
                objuser.UserId  = PR.UserId;
                objuser.type    = PR.Type;
                objuser.gender  = PR.Gender;
                objuser.code    = PR.code;
                objuser.email   = PR.Email;
                objuser.contact = PR.Contact;
                string EncryptedPassword = CryptIt.Encrypt(PR.Password);
                objuser.password     = EncryptedPassword;
                objuser.status       = 1;
                objuser.Islive       = 1;
                objuser.Display      = 1;
                objuser.created_date = DateTime.Now;
                db.tbl_user.Add(objuser);
                db.SaveChanges();

                if (PR.Type == "Student")
                {
                    tbl_student objstudent = new tbl_student();
                    objstudent.UserId = PR.UserId;
                    tbl_user obstudent = db.tbl_user.Where(r => r.code == PR.code).FirstOrDefault();
                    objstudent.UserId       = obstudent.UserId;
                    objstudent.code         = PR.code;
                    objstudent.course_name  = PR.CourseName;
                    objstudent.class_name   = PR.ClassName;
                    objstudent.IsParent     = 0;
                    objstudent.Display      = 1;
                    objstudent.created_date = DateTime.Now;
                    db.tbl_student.Add(objstudent);
                    db.SaveChanges();
                }
                else if (PR.Type == "Faculty")
                {
                    tbl_faculty objfaculty = new tbl_faculty();
                    objfaculty.UserId = PR.UserId;
                    tbl_user obfaculty = db.tbl_user.Where(r => r.code == PR.code).FirstOrDefault();
                    objfaculty.UserId       = obfaculty.UserId;
                    objfaculty.code         = PR.code;
                    objfaculty.department   = PR.CourseName;
                    objfaculty.designation  = PR.Designation;
                    objfaculty.Display      = 1;
                    objfaculty.created_date = DateTime.Now;
                    db.tbl_faculty.Add(objfaculty);
                    db.SaveChanges();
                }
                else if (PR.Type == "Parent")
                {
                    tbl_parent objparent = new tbl_parent();
                    objparent.UserId       = PR.UserId;
                    objparent.relationship = PR.Relationship;
                    tbl_user obstudent = db.tbl_user.Where(r => r.code == PR.code).FirstOrDefault();
                    objparent.UserId       = obstudent.UserId;
                    objparent.code         = PR.code;
                    objparent.Display      = 1;
                    objparent.created_date = DateTime.Now;
                    db.tbl_parent.Add(objparent);
                    db.SaveChanges();
                    //tbl_student objstudent = db.tbl_student.Where(r => r.UserId == PR.UserId).FirstOrDefault();
                    //objstudent.IsParent = 1;
                    //db.SaveChanges();
                }
                else if (PR.Type == "Staff")
                {
                    tbl_staff objstaff = new tbl_staff();
                    objstaff.UserId = objuser.UserId;
                    tbl_user obstaff = db.tbl_user.Where(r => r.code == PR.code).FirstOrDefault();
                    objstaff.UserId       = objstaff.UserId;
                    objstaff.code         = PR.code;
                    objstaff.department   = PR.CourseName;
                    objstaff.designation  = PR.Designation;
                    objstaff.Display      = 1;
                    objstaff.created_date = DateTime.Now;
                    db.tbl_staff.Add(objstaff);
                    db.SaveChanges();
                }
                else
                {
                    return(new Error()
                    {
                        IsError = true, Message = "User Type Not Matched."
                    });
                }
                return(new Result()
                {
                    IsSucess = true, ResultData = "User Saved Successfully."
                });
            }
            catch (Exception ex)
            {
                return(new Error()
                {
                    IsError = true, Message = ex.Message
                });
            }
        }
Esempio n. 9
0
        public object ForgetPassword(ForgetPassword obj)
        {
            if (obj.ContactNumber == null)
            {
                return(new Error()
                {
                    IsError = true, Message = "Contact Number Required"
                });
            }
            GRContext db   = new GRContext();
            string    res  = "";
            var       user = db.tbl_user.Where(r => r.contact == obj.ContactNumber).FirstOrDefault();

            if (user == null)
            {
                return(new Error()
                {
                    IsError = true, Message = "Contact Number Not Found"
                });
            }
            if (user.name.Length > 0)
            {
                res = "Dear <b>" + user.name + "</b> your User Name is <b>" + user.name + "</b> and Password is <b>" + CryptIt.Decrypt(user.password) + "</b>.";
            }
            else
            {
                res = "Sorry we didn't find you in our system.";
                return(res);
            }
            try
            {
                Email objemail = new Email();
                bool  IsDelete;
                if (user.email.Length > 0)
                {
                    //IsDelete = objSMS.SMSSend(MobNo, res);
                    IsDelete = objemail.SendEmail(user.email, res, "Forgot Password", "", "", "", "");
                    res      = "User Name and Password Is Send On Your Registred Email ID. ";
                    return(new Result()
                    {
                        IsSucess = true, ResultData = res
                    });
                }
                else
                {
                    res = "Sorry we didn't find your Email ID in our system.";
                    //return new Error() { IsError = true, Message = res };
                }
                return(res);
            }
            catch (Exception e)
            {
                return(new Error()
                {
                    IsError = true, Message = e.Message
                });
            }
        }
Esempio n. 10
0
        public bool SendEmail(string MailAddress, string msg, string Subject, string UserName, string Password, string Port, string SMTPhost)
        {
            GRContext db = new GRContext();

            try
            {
                var Hostinfo = db.tbl_emailsettings.FirstOrDefault();
                var username = Hostinfo.fromid;


                SmtpClient mailSender = new SmtpClient(Hostinfo.host);//"smtp.gmail.com"

                //mailSender.Port = Int32.Parse(Port );// 25;
                mailSender.Port = 25;


                MailMessage message = new MailMessage();

                System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(username, CryptIt.Decrypt(Hostinfo.password));
                mailSender.Credentials = credentials;
                mailSender.EnableSsl   = true;



                message.From = new MailAddress(username, "GRIEVANCE");
                if (MailAddress.Contains(","))//MailAddress
                {
                    string[] Multiple = MailAddress.Split(',');
                    foreach (string Multi in Multiple)
                    {
                        message.To.Add(new MailAddress(Multi));
                    }
                }
                else
                {
                    message.To.Add(new MailAddress(MailAddress));//MailAddress
                }


                message.Subject    = Subject;
                message.Body       = msg;
                message.IsBodyHtml = true;

                mailSender.Send(message);
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }