public int Put(OnlineDrive model) { int affectedRows = 0; using (ArcanysOnlineEntities dbo = new ArcanysOnlineEntities()) { using (DbContextTransaction transaction = dbo.Database.BeginTransaction(System.Data.IsolationLevel.ReadCommitted)) { try { OnlineDrive updateModel = dbo.OnlineDrives.Find(model.Id); updateModel.Id = model.Id; updateModel.FileNameGUID = model.FileName; updateModel.FileName = model.FileName; updateModel.FilePath = model.FilePath; updateModel.UploadedOn = model.UploadedOn; updateModel.UploadedBy = model.UploadedBy; updateModel.LastUpdatedOn = model.LastUpdatedOn; updateModel.LastUpdatedBy = model.LastUpdatedBy; dbo.OnlineDrives.Add(updateModel); dbo.Entry(updateModel).State = System.Data.Entity.EntityState.Modified; affectedRows = dbo.SaveChanges(); transaction.Commit(); } catch (Exception) { transaction.Rollback(); } finally { transaction.Dispose(); } } } return(affectedRows); }
public int Put(Menu model) { int affectedRows = 0; using (ArcanysOnlineEntities dbo = new ArcanysOnlineEntities()) { using (DbContextTransaction transaction = dbo.Database.BeginTransaction(System.Data.IsolationLevel.ReadCommitted)) { try { Menu updateModel = dbo.Menus.Find(model.PageID); updateModel.PageID = model.PageID; updateModel.PageName = model.PageName; updateModel.PageDescription = model.PageDescription; updateModel.PageURL = model.PageURL; updateModel.PageIcon = model.PageIcon; updateModel.isEnabled = model.isEnabled; updateModel.CreatedOn = model.CreatedOn; updateModel.CreatedBy = model.CreatedBy; dbo.Menus.Add(updateModel); dbo.Entry(updateModel).State = System.Data.Entity.EntityState.Modified; affectedRows = dbo.SaveChanges(); transaction.Commit(); } catch (Exception) { transaction.Rollback(); } finally { transaction.Dispose(); } } } return(affectedRows); }