public Task Save(Employee employee)
        {
            if (employee.Id == Guid.Empty)
            {
                _context.Employees.Add(employee);
            }
            else
            {
                var employeeToUpdate = _context.Employees.First(x => x.Id == employee.Id);
                employeeToUpdate.UpdateProperties(employee);
            }

            return(_context.SaveChangesAsync());
        }
示例#2
0
        public Task Save(Punch punch)
        {
            try
            {
                if (punch.Id == Guid.Empty)
                {
                    _context.Punches.Add(punch);
                }
                else
                {
                    var punchToUpdate = _context.Punches.First(x => x.Id == punch.Id);
                    punchToUpdate.UpdateProperties(punch);
                }

                return(_context.SaveChangesAsync());
            }
            catch (Exception ex)
            {
                throw new Exception("Occured an error trying to save the punch.", ex);
            }
        }