Exemple #1
0
        static public void UpdateAssignmentEvent(Assignment assignment, Event aEvent, int ActiveCourseUserId, ContextBase db)
        {
            //Link to assignment details.
            UrlHelper u = new UrlHelper(System.Web.HttpContext.Current.Request.RequestContext);

            aEvent.Description = "[url:Assignment Page|" + u.Action("Index", "Home", new { assignmentId = assignment.ID, area = "AssignmentDetails" }, System.Web.HttpContext.Current.Request.Url.Scheme) + "]"; //plus.osble.org/AssignmentDetails/" + assignment.ID + "]";
            aEvent.EndDate     = null;
            aEvent.StartDate   = assignment.DueDate;
            aEvent.StartTime   = assignment.DueTime;
            aEvent.PosterID    = ActiveCourseUserId;
            aEvent.Title       = assignment.AssignmentTypeID == (int)AssignmentTypes.DiscussionAssignment? assignment.AssignmentName + " Closes" : assignment.AssignmentName + " Due";
            aEvent.Approved    = true;
            //aEvent.HideTime
            if (aEvent.ID == 0)
            {
                db.Events.Add(aEvent);
                db.SaveChanges();
                assignment.AssociatedEventID = aEvent.ID;
                db.Entry(assignment).State   = System.Data.EntityState.Modified;
                db.SaveChanges();
            }
            else
            {
                db.Entry(aEvent).State = System.Data.EntityState.Modified;
                db.SaveChanges();
            }
            if (assignment.CourseID.HasValue)
            {
                //rebuilds course calendar file upon assignment updates/creations
                using (iCalendarController ical = new iCalendarController())
                {
                    ical.CreateCourseCalendar(assignment.CourseID.Value);
                }
            }
        }
Exemple #2
0
        static public void UpdateDiscussionEvent(DiscussionSetting ds, Event dEvent, int ActiveCourseUserId, ContextBase db)
        {
            //Link to assignment details. Note, since this is hardcoded to osble.org, it will not work locally.

            UrlHelper u = new UrlHelper(System.Web.HttpContext.Current.Request.RequestContext);

            dEvent.Description = "[url:Assignment Page|" + u.Action("Index", "Home", new { assignmentId = ds.AssignmentID, area = "AssignmentDetails" }, System.Web.HttpContext.Current.Request.Url.Scheme) + "]";
            //dEvent.Description = "[url:Assignment Page|plus.osble.org/AssignmentDetails/" + ds.AssignmentID + "]";
            dEvent.EndDate   = null;
            dEvent.StartDate = ds.InitialPostDueDate;
            dEvent.StartTime = ds.InitialPostDueDueTime;
            dEvent.PosterID  = ActiveCourseUserId;
            dEvent.Title     = ds.Assignment.AssignmentName + " Initial Post(s) Due";
            dEvent.Approved  = true;

            if (dEvent.ID == 0)
            {
                db.Events.Add(dEvent);
                db.SaveChanges();
            }
            ds.AssociatedEventID   = dEvent.ID;
            db.Entry(ds).State     = System.Data.EntityState.Modified;
            db.Entry(dEvent).State = System.Data.EntityState.Modified;
            db.SaveChanges();
        }
        public virtual async Task <TEntity> FindAsNoTracking(Guid id)
        {
            var entity = await _dbSet.FindAsync(id);

            _contextBase.Entry(entity).State = EntityState.Detached;

            return(entity);
        }
 public void Update(T objeto)
 {
     using (var data = new ContextBase(_OptionsBuilder))
     {
         data.Entry <T>(objeto).State = EntityState.Modified;
         data.SaveChanges();
     }
 }
Exemple #5
0
        public T Update(T obj)
        {
            using (ContextBase db = new ContextBase())
            {
                db.Entry(obj).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                db.SaveChanges();

                return(obj);
            }
        }
        public virtual async Task <TEntity> FindAsNoTracking(int id)
        {
            var entity = await _dbSet.FindAsync(id);

            if (entity != null)
            {
                _contextBase.Entry(entity).State = EntityState.Detached;
            }

            return(entity);
        }
Exemple #7
0
        public async Task <TEntity> FindAsNoTracking(Guid id)
        {
            var entity = await _entity.FindAsync(id);

            if (entity != null)
            {
                _contextBase.Entry(entity).State = EntityState.Detached;
            }

            return(entity);
        }
 public void Delete(T objeto)
 {
     using (var data = new ContextBase(_OptionsBuilder))
     {
         var entry = data.Entry(objeto);
         if (entry.State == EntityState.Detached)
         {
             data.Set <T>().Attach(objeto);
         }
         data.Set <T>().Remove(objeto);
         data.SaveChanges();
     }
 }
 public EntityState GetState(TEntity entity)
 {
     return(_dbContext.Entry <TEntity>(entity).State);
 }
 public async Task Update(T Objeto)
 {
     _context.Entry(Objeto).State = EntityState.Modified;
     // _context.Set<T>().Update(Objeto);
     await _context.SaveChangesAsync();
 }
 public async Task UpdateAsync(T entity)
 {
     _context.Entry(entity).State = EntityState.Modified;
     await _context.SaveChangesAsync();
 }
 public async Task UpdateAsync(T entity)
 {
     await Task.Run(() => _context.Entry(entity).State = EntityState.Modified);
 }
 public virtual void Excluir(TEntity entity)
 {
     _context.Attach(entity);
     _context.Entry(entity).Property(x => x.Excluido).IsModified = true;
     _context.Entry(entity).Property(x => x.DataDaUltimaAlteracao).IsModified = true;
 }