Exemplo n.º 1
0
        public bool addData(CommonClass custom)
        {
            t_Users tu = new t_Users();

            tu.EMail       = custom.EMail;
            tu.Password    = custom.Password;
            tu.IsActive    = true;
            tu.CreatedDate = DateTime.Now;
            db.t_Users.Add(tu);
            db.SaveChanges();
            int?id = (from s in db.t_Users
                      orderby s.UserId descending
                      select s.UserId).Take(1).SingleOrDefault();

            t_User_PersonalDetails tp = new t_User_PersonalDetails();

            tp.Address     = custom.Address;
            tp.DOB         = custom.DOB;
            tp.FName       = custom.FName;
            tp.LName       = custom.LName;
            tp.Phone       = custom.Phone;
            tp.UserId      = (int)id;
            tp.CreatedDate = DateTime.Now;
            db.t_User_PersonalDetails.Add(tp);
            db.SaveChanges();
            return(true);
        }
Exemplo n.º 2
0
        public IEnumerable <CommonClass1> Edit(int id)
        {
            t_User_PersonalDetails t     = db.t_User_PersonalDetails.Find(id);
            List <CommonClass1>    Listr = new List <CommonClass1>();
            int     uid  = t.UserId;
            t_Users k    = db.t_Users.Find(uid);
            int     uid1 = k.UserId;

            var JoinResult = (from p in db.t_Users
                              join s in db.t_User_PersonalDetails
                              on p.UserId equals t.UserId
                              where p.UserId == uid1
                              select new
            {
                UserPersonalId = t.UserPersonalId__UserPersonalId__UserPersonalId,
                FName = t.FName,
                LName = t.LName,
                Gender = t.Gender,
                Phone = t.Phone,
                DOB = t.DOB,
                EMail = p.EMail,
            }
                              ).ToList();

            foreach (var item in JoinResult)
            {
                CommonClass1 c = new CommonClass1();
                c.UserPersonalId = item.UserPersonalId;
                c.EMail          = item.EMail;
                c.Gender         = item.Gender;
                c.FName          = item.FName;
                c.LName          = item.LName;
                c.Phone          = item.Phone;
                c.DOB            = item.DOB;
                Listr.Add(c);
            }
            return(Listr);
            //db.t_User_PersonalDetails.ToList();
        }