public TimeEntry Create(TimeEntry timeEntry)
        {
            TimeEntryRecord record = _context.TimeEntryRecords.Add(timeEntry.ToRecord()).Entity;

            _context.SaveChanges();
            return(record.ToEntity());
        }
 public static TimeEntry toEntity(this TimeEntryRecord record) => new TimeEntry
 {
     Id        = record.Id,
     ProjectId = record.ProjectId,
     UserId    = record.UserId,
     Date      = record.Date,
     Hours     = record.Hours
 };
Esempio n. 3
0
        public TimeEntry Create(TimeEntry timeEntry)
        {
            TimeEntryRecord recordToCreated = timeEntry.ToRecord();

            timeEntryContext.TimeEntryRecords.Add(recordToCreated);
            timeEntryContext.SaveChanges();

            return(Find(recordToCreated.Id.Value));
        }
        public void Delete(long id)
        {
            TimeEntryRecord timeEntryRecord = _context.TimeEntryRecords.AsNoTracking().Single(t => t.Id == id);

            if (timeEntryRecord != null)
            {
                _context.Remove(timeEntryRecord);
                _context.SaveChanges();
            }
        }
        public TimeEntry Create(TimeEntry timeEntry)
        {
            TimeEntryRecord record = timeEntry.ToRecord();

            EntityEntry <TimeEntryRecord> entity = _context.Add <TimeEntryRecord>(record);

            _context.SaveChanges();

            return(entity.Entity.ToEntity());
        }
        public TimeEntry Update(long id, TimeEntry timeEntry)
        {
            TimeEntryRecord record = timeEntry.ToRecord();

            record.Id = id;

            _context.TimeEntryRecords.Update(record);
            _context.SaveChanges();
            return(Find(id));
        }
        public TimeEntry Update(long id, TimeEntry timeEntry)
        {
            TimeEntryRecord theUpdatedRecord = timeEntry.ToRecord();

            theUpdatedRecord.Id = id;

            Context.Update(theUpdatedRecord);
            Context.SaveChanges();

            return(Find(id));
        }
Esempio n. 8
0
        public TimeEntry Update(long id, TimeEntry timeEntry)
        {
            TimeEntryRecord recordToCreated = timeEntry.ToRecord();

            recordToCreated.Id = id;

            timeEntryContext.TimeEntryRecords.Update(recordToCreated);
            timeEntryContext.SaveChanges();

            return(Find(recordToCreated.Id.Value));
        }
        public TimeEntry Update(long id, TimeEntry timeEntry)
        {
            TimeEntryRecord timeEntryRecord = _context.Find <TimeEntryRecord>(id);

            timeEntryRecord.UserId    = timeEntry.UserId;
            timeEntryRecord.ProjectId = timeEntry.ProjectId;
            timeEntryRecord.Date      = timeEntry.Date;
            timeEntryRecord.Hours     = timeEntry.Hours;

            _context.Update(timeEntryRecord);
            _context.SaveChanges();

            return(timeEntryRecord.ToEntity());
        }
        public TimeEntry Find(long id)
        {
            TimeEntryRecord timeEntryRecord = _context.TimeEntryRecords.AsNoTracking().Single(t => t.Id == id);

            return(timeEntryRecord.ToEntity());
        }