예제 #1
0
        public IHttpActionResult PutLogItem(long id, LogItem logItem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != logItem.Id)
            {
                return(BadRequest());
            }

            db.Entry(logItem).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LogItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public async Task <IActionResult> PutLogs(string id, Logs logs)
        {
            if (id != logs.LogId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
예제 #3
0
        public async Task <int> Put(User user)
        {
            var userTracker = _ctx.Set <User>().Local
                              .FirstOrDefault(entry => entry.UserId.Equals(user.UserId));

            if (userTracker != null)
            {
                _ctx.Entry(userTracker).State = EntityState.Detached;
            }
            _ctx.Entry(user).State = EntityState.Modified;
            _ctx.Entry(user).Property("Password").IsModified    = false;
            _ctx.Entry(user).Property("CreatedDate").IsModified = false;
            user.UpdatedDate = DateTime.Now;
            await _ctx.SaveChangesAsync();

            return(user.UserId);
        }
예제 #4
0
        public override void Update(Log item)
        {
            item.Status       = DataStatus.Updated;
            item.ModifiedDate = DateTime.Now;
            Log ToBeUpdated = GetByID(item.ID);

            ldb.Entry(ToBeUpdated).CurrentValues.SetValues(item);
            Save();
        }
예제 #5
0
        public async Task <TEntity> Update(TEntity entity)
        {
            var addedEntry = _ctx.Update(entity);

            _ctx.Entry(entity).Property("CreatedDate").IsModified = false;
            await _ctx.SaveChangesAsync();

            return(entity);
        }
예제 #6
0
        public TEntity Update(TEntity obj)
        {
            var entry = Db.Entry(obj);

            DbSet.Attach(obj);
            entry.State = EntityState.Modified;
            SaveChanges();
            return(obj);
        }
예제 #7
0
        public void Edit(Log entry)
        {
            var log = Data.FirstOrDefault(t => t.Id == entry.Id);

            if (log != null)
            {
                _context.Entry(entry).State = System.Data.Entity.EntityState.Modified;
                _context.SaveChanges();
            }
        }
        public void Edit(ElectCity entry)
        {
            var city = Data.FirstOrDefault(t => t.Id == entry.Id);

            city.Name = entry.Name;
            if (city != null)
            {
                _context.Entry(city).State = System.Data.Entity.EntityState.Modified;
                _context.SaveChanges();
            }
        }
예제 #9
0
        public async Task <IActionResult> PutLog(long id, LogViewModel logViewModel)
        {
            if (id != logViewModel.Id)
            {
                return(BadRequest());
            }

            var log = await _context.Logs.FindAsync(id);

            if (log == null)
            {
                return(NotFound());
            }

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

            if (!String.IsNullOrEmpty(logViewModel.IPAddress))
            {
                log.IPAddress = logViewModel.IPAddress;
            }

            if (!String.IsNullOrEmpty(logViewModel.LogDate))
            {
                log.LogDate = DateTime.Parse(logViewModel.LogDate);
            }

            if (!String.IsNullOrEmpty(logViewModel.LogMessage))
            {
                log.LogMessage = logViewModel.LogMessage;
            }

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

            return(NoContent());
        }
예제 #10
0
 /// <summary>
 /// Create new log.
 /// </summary>
 /// <param name="item">New log.</param>
 public void Create(T item)
 {
     _logContext.Entry(item).State = System.Data.Entity.EntityState.Added;
 }