public virtual void Delete(TEntity entityToDelete) { if (context.Entry(entityToDelete).State == EntityState.Detached) { dbSet.Attach(entityToDelete); } dbSet.Remove(entityToDelete); }
public ProductFashtionImagesDto get(string id) { try { ProductFashtionImages bb = _context.ProductFashtionImages.Find(id); _context.Entry(bb).Reference(b => b.ImagesFashtion).Load(); _context.Entry(bb).Reference(b => b.ProductFashtion).Load(); return(mapper.Map <ProductFashtionImages, ProductFashtionImagesDto>(bb)); } catch (Exception) { return(null); } }
public BankBranchDto get(string id) { try { BankBranch bb = _context.BankBranch.Find(id); _context.Entry(bb).Reference(b => b.Bank).Load(); _context.Entry(bb).Reference(b => b.Province).Load(); return(mapper.Map <BankBranch, BankBranchDto>(bb)); } catch (Exception) { return(null); } }
public ActionResult Edit([Bind(Include = "ProductoID,Codigo,NombreProducto,Especificaciones,Valor,EmpresaID")] Producto producto) { if (ModelState.IsValid) { bool hasErrors = false; DbContextTransaction Transaction = null; try { Transaction = db.Database.BeginTransaction(); producto.EmpresaID = ApplicationContext.CurrentUser.EmpresaID; db.Entry(producto).State = EntityState.Modified; db.SaveChanges(); Transaction.Commit(); } catch (Exception eX) { if (Transaction != null) { Transaction.Rollback(); } ModelState.AddModelError("", eX.Message); hasErrors = true; } if (!hasErrors) { return(RedirectToAction("Index")); } } ViewBag.EmpresaID = new SelectList(db.Empresas, "EmpresaID", "Nombre", producto.EmpresaID); return(View(producto)); }
public async Task <bool> UpdateContactAsync(ViewContactLess model) { using (var transaction = _database.Database.BeginTransaction()) { try { var original = await _database.Contacts.FirstOrDefaultAsync(p => p.GuID == model.GuID); var replace = new Contact(); AutoMapper.Mapper.Map(model, replace); replace.ContactId = original.ContactId; replace.DateModified = DateTime.UtcNow; _database.Entry(original).CurrentValues.SetValues(replace); await _database.SaveChangesAsync(); transaction.Commit(); return(true); } catch { transaction.Rollback(); throw; } } }
public async Task <IActionResult> UpdateEMp(EmployeeInfo em) { db.Entry(em).State = EntityState.Modified; await db.SaveChangesAsync(); return(NoContent()); }
public override void Delete(Activity obj) { using (CRMContext context = new CRMContext()) { Activity p = context.Set <Activity>().Find(obj.id); context.Entry(p).State = EntityState.Deleted; context.SaveChanges(); } }
public override void Delete(UserPartition obj) { using (CRMContext context = new CRMContext()) { UserPartition p = context.Set <UserPartition>().Find(obj.id); context.Entry(p).State = EntityState.Deleted; context.SaveChanges(); } }
public ActionResult Edit([Bind(Include = "DonationID,DonorID,DonationArea,DonationAmount")] Donation donation) { if (ModelState.IsValid) { db.Entry(donation).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(donation)); }
public ActionResult Edit([Bind(Include = "AffiliationID,ConstituentID,EmployerName")] Affiliation affiliation) { if (ModelState.IsValid) { db.Entry(affiliation).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(affiliation)); }
public ActionResult Edit([Bind(Include = "SectorEconomicoID,SectorEconomico")] SectoresEconomicos sectoresEconomicos) { if (ModelState.IsValid) { db.Entry(sectoresEconomicos).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(sectoresEconomicos)); }
public ActionResult Edit([Bind(Include = "VolunteerID,OccurenceID,VolunteerType")] Volunteer volunteer) { if (ModelState.IsValid) { db.Entry(volunteer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(volunteer)); }
public ActionResult Edit([Bind(Include = "EmployeeID,Forename,Surname,DateOfBirth")] Employee employee) { if (ModelState.IsValid) { db.Entry(employee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(employee)); }
public ActionResult Edit([Bind(Include = "PeticionID,FechaRegistro,Titulo,Descripcion,TipoPeticion,FechaSolucion,Solucion,ResueltaPor,EmpresaID,UserID")] Peticion peticion) { if (ModelState.IsValid) { db.Entry(peticion).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(peticion)); }
public ActionResult Edit([Bind(Include = "TeacherID")] Teacher teacher) { if (ModelState.IsValid) { db.Entry(teacher).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(teacher)); }
public ActionResult Edit([Bind(Include = "CourseID,CourseName,CourseCategory,CourseDate")] Course course) { if (ModelState.IsValid) { db.Entry(course).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(course)); }
public ActionResult Edit([Bind(Include = "ClientID,Forename,Surname,DateOfBirth,AddressDetails")] Client client) { if (ModelState.IsValid) { db.Entry(client).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(client)); }
public ActionResult Edit([Bind(Include = "Id,Date,Description,ContactId")] Annotation annotation) { if (ModelState.IsValid) { db.Entry(annotation).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "Contacts")); } return(View(annotation)); }
public ActionResult Edit([Bind(Include = "ConstituentID,IsPerson,FirstName,LastName,Address,City,State,ZipCode,Country,Email,PhoneNumber,ReferralMethod,ActiveSince,AgeRange,Notes")] Constituent constituent) { if (ModelState.IsValid) { db.Entry(constituent).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(constituent)); }
public ActionResult Edit([Bind(Include = "CiudadID,Ciudad")] Ciudades ciudades) { if (ModelState.IsValid) { db.Entry(ciudades).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(ciudades)); }
public ActionResult Edit([Bind(Include = "ArtistID,ArtistCategory")] Artist artist) { if (ModelState.IsValid) { db.Entry(artist).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(artist)); }
public ActionResult Edit([Bind(Include = "OccurenceID,OccurenceName,OccurenceCategory,OccurenceDate")] Occurence occurence) { if (ModelState.IsValid) { db.Entry(occurence).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(occurence)); }
public ActionResult Edit([Bind(Include = "Id,Name,Email,PhoneNumber")] Contact contact) { if (ModelState.IsValid) { db.Entry(contact).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(contact)); }
public ActionResult Edit([Bind(Include = "ContactoID,ClienteID,Nombre,Cargo,Telefono,Celular,Email")] Contactos contactos) { if (ModelState.IsValid) { db.Entry(contactos).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ClienteID = new SelectList(db.Clientes.Where(c => c.EmpresaID.Equals(ApplicationContext.CurrentUser.EmpresaID)) .OrderBy(c => c.Nombre), "ClienteID", "Nombre"); return(View(contactos)); }
public CategoryDto get(string id) { try { var c = _context.Category.Find(id); _context.Entry(c).Reference(cm => cm.CategoryMain).Load(); return(mapper.Map <Category, CategoryDto>(c)); } catch (Exception) { return(null); } }
public BusinessDto get(string id) { try { Business bs = _context.Business.Find(id); _context.Entry(bs).Collection(cs => cs.Customer).Load(); return(mapper.Map <Business, BusinessDto>(bs)); } catch (Exception ex) { return(null); } }
public CustomerGroupDto get(string id) { try { CustomerGroup cg = _context.CustomerGroup.Find(id); _context.Entry(cg).Reference(c => c.Customer).Load(); return(mapper.Map <CustomerGroup, CustomerGroupDto>(cg)); } catch (Exception) { return(null); } }
public async Task <ActionResult <int> > UpdateEMp([FromBody] EmployeeInfo em) { //db.EmployeeInfo.AsNoTracking(); //db.Entry(em).State = EntityState.Modified; //int task= await db.SaveChangesAsync(); //db.Entry(em).State = EntityState.Deleted; //return task; db.Entry(em).State = EntityState.Modified; return(await db.SaveChangesAsync()); }
public BankDto get(string id) { try { Bank b = _context.Bank.Find(id); _context.Entry(b).Collection(bb => bb.BankBranch).Load(); return(mapper.Map <Bank, BankDto>(b)); } catch (Exception) { return(null); } }
public CountryDto get(string id) { try { Country _tCountry = _context.Country.Find(id); // Country _tCountry = _context.Country.FirstOrDefault(x => x.Id == id); _context.Entry(_tCountry).Collection(b => b.Province).Load(); return(mapper.Map <Country, CountryDto>(_tCountry)); } catch (Exception) { return(null); } }