/// <summary> /// Ataches an entitiy to the context without calling the context save changes. /// </summary> /// <param name="entitiy">The entitiy that will be added to the context without saving changes</param> /// <returns>The atached created entitiy</returns> public Keyword CreateWithNoSave(Keyword entitiy) { // only add the keyword to the contextr with the added state var addedKeyword = _context.Keywords.Add(entitiy); _context.Entry(entitiy).State = EntityState.Added; return(addedKeyword); }
/// <summary> /// Ataches an entitiy to the context without calling the context save changes. /// </summary> /// <param name="entitiy">The entitiy that will be added to the context without saving changes</param> /// <returns>The atached created entitiy</returns> public Category CreateWithNoSave(Category entitiy) { // we are going to atach with the added/new state without calling save changes // add an entry for the entitiy setting the state to added var addedEntitiy = _context.Categories.Add(entitiy); _context.Entry(entitiy).State = EntityState.Added; return(addedEntitiy); }
/// <summary> /// Ataches an entitiy to the context without calling the context save changes. /// </summary> /// <param name="entitiy">The entitiy that will be added to the context without saving changes</param> /// <returns>The atached created entitiy</returns> public Document CreateWithNoSave(Document entitiy) { // Add the document to the context with the added state without calling // save changes on the context var addedDocument = _context.Documents.Add(entitiy); _context.Entry(entitiy).State = EntityState.Added; return(addedDocument); }
public async Task <IActionResult> PutLog(int id, Log log) { if (id != log.LogId) { return(BadRequest()); } _context.Entry(log).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LogExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
/// <summary> /// Ataches an entitiy to the context without calling the context save changes. /// </summary> /// <param name="entitiy">The entitiy that will be added to the context without saving changes</param> /// <returns>The atached created entitiy</returns> public User CreateWithNoSave(User entitiy) { // add the user to the context with the add state without calling save changes var addedUser = _dsContext.Users.Add(entitiy); _dsContext.Entry(entitiy).State = EntityState.Added; return(addedUser); }