public void CreateUser(Registration model) { using (var transaction = context.Database.BeginTransaction()) { TblUserDetails user = new TblUserDetails { Fname = model.Fname, Lname = model.Lname, EmailId = model.EmailID, Phone = Convert.ToDecimal(model.Phone), Address = model.Address }; context.TblUserDetails.Add(user); context.SaveChanges(); string adminchk = model.IsAdmin ? "Y" : "N"; TblLoginDetails login = new TblLoginDetails { UserName = model.EmailID, Password = model.Password, IsAdmin = adminchk, UserId = user.UserId }; context.TblLoginDetails.Add(login); context.SaveChanges(); transaction.Commit(); } }
public void UpdateUser(int id, Registration model) { using (var transaction = context.Database.BeginTransaction()) { TblUserDetails user = context.TblUserDetails.Where(u => u.UserId == id).FirstOrDefault(); user.Fname = model.Fname; user.Lname = model.Lname; user.EmailId = model.EmailID; user.Phone = Convert.ToDecimal(model.Phone); user.Address = model.Address; context.SaveChanges(); string adminchk = model.IsAdmin ? "Y" : "N"; TblLoginDetails login = context.TblLoginDetails.Where(u => u.UserId == id).FirstOrDefault(); login.UserName = model.EmailID; login.Password = model.Password; login.IsAdmin = adminchk; context.SaveChanges(); transaction.Commit(); } }
public IActionResult GetUserByUserId(string Id) { TblUserDetails _user = _userService.GetUserByUserId(Id, Context); return(Ok(_user)); }