Пример #1
0
        //public async Task<bool> Delete(AspNetRole objDelete)
        //{
        //    StackFrame stackFrame = new StackFrame();
        //    MethodBase methodBase = stackFrame.GetMethod();

        //    int rowEffected = 0;
        //    try
        //    {
        //        OpenEntityConnection();
        //        if (objDelete != null) //Definsive Programming
        //        {
        //            string strsql ="delete "

        //            rowEffected = await objPharmaEntities.SaveChangesAsync();
        //        }

        //    }
        //    catch (Exception ex)
        //    {
        //        catchEntityvalidation((System.Data.Entity.Validation.DbEntityValidationException)ex, System.Runtime.InteropServices.Marshal.GetExceptionCode().ToString(),
        //                this.UserNameProperty.ToString(), this.GetType().Name.ToString(), methodBase.Name.ToString());
        //        rowEffected = -1;
        //        ex.InnerException.Message.ToString();
        //    }
        //    finally
        //    {
        //        CloseEntityConnection();
        //    }

        //    if (rowEffected > 0)
        //        return true;
        //    else
        //        return false;

        //}
        //public bool DeleteTask(Hr_Users objDelete)
        //{
        //    StackFrame stackFrame = new StackFrame();
        //    MethodBase methodBase = stackFrame.GetMethod();

        //    bool task = Delete(objDelete).Result;
        //    return task;

        //}

        public Hr_Users GetById(string Rec_ID)
        {
            StackFrame stackFrame = new StackFrame();
            MethodBase methodBase = stackFrame.GetMethod();

            try
            {
                OpenEntityConnection();
                Hr_Users ObjForGetEntity = (from objLinq in objPharmaEntities.Hr_Users
                                            where objLinq.UserId == Rec_ID
                                            select objLinq).FirstOrDefault();
                return(ObjForGetEntity);
            }
            catch (Exception ex)
            {
                catchEntityvalidation((System.Data.Entity.Validation.DbEntityValidationException)ex, System.Runtime.InteropServices.Marshal.GetExceptionCode().ToString(),
                                      this.UserNameProperty.ToString(), this.GetType().Name.ToString(), methodBase.Name.ToString());
                ex.InnerException.Message.ToString();
                return(null);
            }
            finally
            {
                CloseEntityConnection();
            }
        }
Пример #2
0
        public static dynamic SelectByNameAndPassword(string LoginName, string Password, string CompanyId, string BranchNo)
        {
            int           result = 0;
            List <string> roles  = new List <string>();

            roles.Add("Admin");
            CustomUserAuthorizeController auth = new CustomUserAuthorizeController();
            int value = auth.validate(roles);

            if (value == (int)UserStatusEnum.UserStatus.Authorized)
            {
                Hr_Users obj = UsersBL.GetObject().SelectByNameAndPassword(LoginName, Password, CompanyId, BranchNo);
                if (obj != null && obj.UserId != null)
                {
                    result = 1;
                    HttpContext.Current.Session["Hr_UserDL"] = obj;
                }
                else
                {
                    result = 0;
                }
            }

            return(result);
            // return Ok(result);
        }
Пример #3
0
        public async Task <int> Insert(Hr_Users objInsert)
        {
            StackFrame stackFrame = new StackFrame();
            MethodBase methodBase = stackFrame.GetMethod();

            int RowEffected = 0;

            try
            {
                if (objInsert != null)
                {
                    //Password: Admin@123
                    OpenEntityConnection();
                    objInsert.Password = Encrypt("user@123456");
                    objPharmaEntities.Hr_Users.Add(objInsert);
                    RowEffected = await objPharmaEntities.SaveChangesAsync();
                }
            }
            catch (Exception ex)
            {
                catchEntityvalidation((System.Data.Entity.Validation.DbEntityValidationException)ex, System.Runtime.InteropServices.Marshal.GetExceptionCode().ToString(),
                                      this.UserNameProperty.ToString(), this.GetType().Name.ToString(), methodBase.Name.ToString());
                RowEffected = -1;
                ex.InnerException.Message.ToString();
            }
            finally
            {
                CloseEntityConnection();
            }

            return(RowEffected);
        }
Пример #4
0
        // Calling the method of using Async


        public int InsertTask(Hr_Users objInsert)
        {
            StackFrame stackFrame = new StackFrame();
            MethodBase methodBase = stackFrame.GetMethod();

            int task = Insert(objInsert).Result;

            return(task);
        }
Пример #5
0
        public bool DeleteTask(Hr_Users objDelete)
        {
            StackFrame stackFrame = new StackFrame();
            MethodBase methodBase = stackFrame.GetMethod();

            bool task = Delete(objDelete).Result;

            return(task);
        }
Пример #6
0
        public async Task <bool> Update(Hr_Users objUpdate)
        {
            StackFrame stackFrame = new StackFrame();
            MethodBase methodBase = stackFrame.GetMethod();

            int rowEffected = 0;

            try
            {
                if (objUpdate != null) //Definsive Programming
                {
                    OpenEntityConnection();
                    Hr_Users ObjForUpdate = (from objLinq in objPharmaEntities.Hr_Users
                                             where objLinq.UserId == objUpdate.UserId
                                             select objLinq).FirstOrDefault();
                    ObjForUpdate.Password      = Encrypt(objUpdate.Password);
                    ObjForUpdate.Email         = objUpdate.Email;
                    ObjForUpdate.Emp_Serial_No = objUpdate.Emp_Serial_No;

                    ObjForUpdate.UpdateUser = objUpdate.UpdateUser;
                    ObjForUpdate.UpdateDate = DateTime.Today;
                    rowEffected             = await objPharmaEntities.SaveChangesAsync();
                }
            }
            catch (Exception ex)
            {
                catchEntityvalidation((System.Data.Entity.Validation.DbEntityValidationException)ex, System.Runtime.InteropServices.Marshal.GetExceptionCode().ToString(),
                                      this.UserNameProperty.ToString(), this.GetType().Name.ToString(), methodBase.Name.ToString());
                rowEffected = -1;
                ex.InnerException.Message.ToString();
            }
            finally
            {
                CloseEntityConnection();
            }

            if (rowEffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #7
0
        public Hr_Users SelectByNameAndPassword(string UserName, string StrPassword, string StrCompanyId, string StrBranchNo)
        {
            StackFrame stackFrame = new StackFrame();
            MethodBase methodBase = stackFrame.GetMethod();

            try
            {
                OpenEntityConnection();

                string StrPasswordNew = Encrypt(StrPassword).ToString();

                Hr_Users ObjForGetEntity = (from objLinq in objPharmaEntities.Hr_Users
                                            // where objLinq.UserName == UserName && objLinq.Password == StrPassword
                                            //
                                            where objLinq.UserName == UserName && objLinq.Password == StrPasswordNew &&
                                            objLinq.Company_Id == StrCompanyId && objLinq.Branch_Id == StrBranchNo
                                            select objLinq).FirstOrDefault();
                return(ObjForGetEntity);
            }
            catch (DbEntityValidationException ex)
            {
                Exception raise = ex;

                foreach (var validationErrors in ex.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);

                        // SaveErrorLog(errorCode, message, UserName, StrClassName, strFunctionName);
                    }
                }

                throw raise;
            }
            catch (Exception ex)
            {
                ////Exception raise = ex;

                ////foreach (var validationErrors in ex.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);

                ////        // SaveErrorLog(errorCode, message, UserName, StrClassName, strFunctionName);


                ////    }

                //}

                //throw raise;

                catchEntityvalidation((System.Data.Entity.Validation.DbEntityValidationException)ex, System.Runtime.InteropServices.Marshal.GetExceptionCode().ToString(),
                                      this.UserNameProperty.ToString(), this.GetType().Name.ToString(), methodBase.Name.ToString());
                ex.InnerException.Message.ToString();
                return(null);
            }
            finally
            {
                CloseEntityConnection();
            }
        }