public long Insert(BalUser bal) { try { if (dbcontext == null) { dbcontext = new TransformerEntities(); } User_db dal = new User_db(); dal.Username = bal.Username; dal.Password = bal.Password; dal.Phone = bal.Phone; dal.Address = bal.Address; dal.Is_Active = bal.Is_Active; dal.Name = bal.Name; dal.Email = bal.Email; dal.Year = bal.Year; dbcontext.User_db.Add(dal); dbcontext.SaveChanges(); return(dal.PK_User_Id); } catch (Exception ex) { throw ex; } }
public void Update(BalUser bal, int id) { try { if (dbcontext == null) { dbcontext = new TransformerEntities(); } User_db abc = dbcontext.User_db.FirstOrDefault(c => c.PK_User_Id == id); if (abc != null) { abc.Username = bal.Username; abc.Password = bal.Password; abc.Phone = bal.Phone; abc.Address = bal.Address; abc.Is_Active = true; abc.Name = bal.Name; dbcontext.SaveChanges(); } } catch (Exception ex) { throw ex; } }