Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="u"></param>
        /// <returns></returns>
        public int InsertUser(tbUser u)
        {
            tblUser u1 = new tblUser();
            tbUser  c1 = GetUserDetail().Find(delegate(tbUser o) { return(u.EmailId.Trim().Equals(o.EmailId.Trim())); });

            if (c1 != null && c1.Id != u.Id)
            {
                return(0);
            }
            else
            {
                u1.FirstName   = u.FName;
                u1.LastName    = u.LName;
                u1.EmailId     = u.EmailId;
                u1.CellPhoneNo = u.CellPhone;
                u1.PhoneNo     = u.PhoneNumber;
                u1.Id          = u.Id;
                u1.Password    = u.Password;
                u1.Status      = u.Status;
                u1.CreatedDate = DateTime.Now;
                u1.ModifyDate  = DateTime.Now;
                u1.IsDeleted   = false;
                db.tblUsers.InsertOnSubmit(u1);
                db.SubmitChanges();
                return(u1.Id);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="UserId"></param>
        /// <returns></returns>
        public List <tbUser> GetUserDetail()
        {
            var user = (from t in db.tblUsers where t.Id != 1 && t.IsDeleted == false select t).ToList();

            user = user.OrderByDescending(o => o.CreatedDate).ToList();
            List <tbUser> list = new List <tbUser>();

            if (user != null)
            {
                foreach (var u in user)
                {
                    tbUser u1 = new tbUser();
                    u1.FName       = u.FirstName;
                    u1.LName       = u.LastName;
                    u1.EmailId     = u.EmailId;
                    u1.CellPhone   = u.CellPhoneNo;
                    u1.PhoneNumber = u.PhoneNo;
                    u1.Id          = u.Id;
                    u1.Password    = u.Password;
                    u1.Status      = u.Status.Value;
                    if (u.CreatedDate != null)
                    {
                        u1.CreatedDate = u.CreatedDate.Value;
                    }
                    else
                    {
                        u1.CreatedDate = DateTime.Now;
                    }
                    if (u.ModifyDate != null)
                    {
                        u1.ModifyDate = u.ModifyDate.Value;
                    }
                    else
                    {
                        u1.ModifyDate = DateTime.Now;
                    }
                    list.Add(u1);
                }
                return(list);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="u"></param>
        /// <returns></returns>
        public bool UpdateUser(tbUser u)
        {
            tblUser u1   = new tblUser();
            var     info = (from u2 in db.tblUsers where u2.Id == u.Id select u2).FirstOrDefault();
            tbUser  c1   = GetUserDetail().Find(delegate(tbUser o) { return(u.EmailId.Trim().Equals(o.EmailId.Trim())); });

            u1 = (tblUser)info;
            if (c1 != null && c1.Id != u.Id)
            {
                return(false);
            }
            else
            {
                if (info != null)
                {
                    u1.Id          = u.Id;
                    u1.FirstName   = u.FName;
                    u1.LastName    = u.LName;
                    u1.PhoneNo     = u.PhoneNumber;
                    u1.CellPhoneNo = u.CellPhone;
                    u1.EmailId     = u.EmailId;
                    //u1.CreatedDate = u.CreatedDate;
                    u1.ModifyDate = DateTime.Now;
                    u1.Password   = u.Password;
                    u1.Status     = u.Status;
                }
                try
                {
                    db.SubmitChanges();
                    return(true);
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }
        }