public bool SaveEdit(Marketing mkt) { using (SmartBagEntities entities = new SmartBagEntities()) { try { TBT_MARKETING m = entities.TBT_MARKETING.Find((decimal)mkt.CodMarketing); m.Titulo = mkt.Titulo; m.CodTipoMarketing = mkt.CodTipoMarketing; m.Descricao = mkt.Descricao; m.TipoArquivo = mkt.TipoArquivo; m.NomeArquivo= mkt.NomeArquivo; m.IndAtivo = mkt.Ativo ? 1 : 0; m.CodMarca = mkt.CodMarca; entities.Entry(m).State = EntityState.Modified; entities.SaveChanges(); return true; } catch (Exception e) { return false; } } }
public Marketing IncluirMkt(Marketing mkt) { using (SmartBagEntities entities = new SmartBagEntities()) { try { TBT_MARKETING m = new TBT_MARKETING(); m.Titulo = mkt.Titulo; m.CodTipoMarketing = mkt.CodTipoMarketing; m.Descricao = mkt.Descricao; m.TipoArquivo = mkt.TipoArquivo; m.NomeArquivo = mkt.NomeArquivo; m.IndAtivo = mkt.Ativo ? 1 : 0; m.CodMarca = mkt.CodMarca; entities.TBT_MARKETING.Add(m); entities.Entry(m).State = EntityState.Added; entities.SaveChanges(); //TBT_MARKETING m2 = entities.TBT_MARKETING.Find((decimal)mkt.CodMarketing); //m2.CodMarketing = m2.ID; //entities.Entry(m2).State = EntityState.Modified; //entities.SaveChanges(); return GetMarketing((int)m.CodMarketing); } catch (Exception e) { return null; } } }
public bool UserEdit(Usuario usr) { using (SmartBagEntities entities = new SmartBagEntities()) { try { TBT_USUARIO editedUser = entities.TBT_USUARIO.Where(x => x.CodUsuario == usr.CodUsuario).Select(x => x).FirstOrDefault(); editedUser.IndAtivo = usr.Ativo ? 1 : 0; editedUser.CodPessoa = usr.CodPessoa; editedUser.Login = usr.Login; if (!string.IsNullOrEmpty(usr.Senha)) editedUser.Senha = usr.Senha; entities.Entry(editedUser).State = EntityState.Modified; entities.SaveChanges(); return true; } catch (Exception) { return false; } } }