public bool UpdateTechRole(string oldId, TechRoleDAO trdao) { try { if (!string.IsNullOrWhiteSpace(oldId) && trdao != null) { TechRole ns = mapper.MapToEntity(trdao); TechRole old = ef.GetTechRoles().FirstOrDefault(a => a.TRName.Equals(oldId)); ns.TechRoleID = old.TechRoleID; return(ef.UpdateTechRole(old, ns)); } return(false); } catch (Exception e) { return(false); } }
/// <summary> /// delete tech role /// </summary> /// <param name="trdao"></param> /// <returns></returns> public bool DeleteTechRole(TechRoleDAO trdao) { try { if (trdao != null) { TechRole tr = mapper.MapToEntity(trdao); var toDelete = ef.GetTechRoles().FirstOrDefault((m => m.TRName == tr.TRName)); return(ef.DeleteTechRole(toDelete)); } else { return(false); } } catch (Exception e) { throw; } }
public bool DeleteTechRole(TechRole tr) { db.TechRole.Remove(tr); return(db.SaveChanges() > 0); }
public bool InsertTechRole(TechRole tr) { db.TechRole.Add(tr); return(db.SaveChanges() > 0); }
public bool UpdateTechRole(TechRole old, TechRole tr) { db.Entry(old).CurrentValues.SetValues(tr); return(db.SaveChanges() > 0); }