예제 #1
0
        public async Task <ActionResult <Entry> > edit(Entry entry)
        {
            var oldentry = _context.Entry.Where(s => s.id == entry.id).FirstOrDefault();

            oldentry.entry = entry.entry;

            _context.Entry(oldentry).State = EntityState.Modified;


            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EntryExists(entry.id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(oldentry);
        }
예제 #2
0
        public User lastloginupdate(int id)
        {
            var user = _context.User.Find(id);

            user.lastLoginDate         = DateTime.Now;
            _context.Entry(user).State = EntityState.Modified;
            _context.SaveChanges();

            return(user);
        }
예제 #3
0
        public void SubjectCount()
        {
            var subjectcount = _context.Subject.Select(p => p.id).ToList();

            for (int i = 0; i < subjectcount.Count(); i++)
            {
                var subject    = _context.Subject.Find(subjectcount[i]);
                var totalcount = _context.Entry.Where(p => p.subjectId == subject.id).Count();
                subject.totalCount            = totalcount;
                _context.Entry(subject).State = EntityState.Modified;
            }
            _context.SaveChanges();
        }
예제 #4
0
        public async Task <IActionResult> PutMessage(int id, Message message)
        {
            if (id != message.id)
            {
                return(BadRequest());
            }

            _context.Entry(message).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MessageExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #5
0
        public async Task <IActionResult> PutUserLevel(int id, UserLevel userLevel)
        {
            if (id != userLevel.id)
            {
                return(BadRequest());
            }

            _context.Entry(userLevel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserLevelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutAnnouncement(int id, Announcement announcement)
        {
            if (id != announcement.id)
            {
                return(BadRequest());
            }

            _context.Entry(announcement).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AnnouncementExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }