Beispiel #1
0
 public Guid AddNewManager(ManagerBaseDto manager)
 {
     using var transaction = _dbContext.Database.BeginTransaction();
     try
     {
         var id = AddManager(manager);
         transaction.Commit();
         return(id);
     }
     catch (Exception e)
     {
         transaction.Rollback();
         return(Guid.Empty);
     }
 }
Beispiel #2
0
        private Guid AddManager(ManagerBaseDto managerDto)
        {
            var manager = _dbContext.Managers.FirstOrDefault(x => x.Id == managerDto.Id);

            if (manager == null)
            {
                var newManager = new Manager
                {
                    Name = managerDto.Name
                };
                _dbContext.Managers.Add(newManager);
                _dbContext.SaveChanges();

                return(newManager.Id);
            }

            return(manager.Id);
        }