示例#1
0
        public AdminDTO CreateAdmin(string adminId)
        {
            var admin = _repositoryAdmin.GetAdminByID(adminId);

            if (admin != null)
            {
                return(null);
            }
            var newAdmin     = _adminMapper.MapToModel(adminId);
            var createdAdmin = _repositoryAdmin.CreateAdmin(newAdmin);

            try
            {
                _repositoryAdmin.SaveChanges();
            }
            catch (DbUpdateException)
            {
                return(null);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            return(_adminMapper.MapToDTO(createdAdmin));
        }
示例#2
0
        public AdminDTO MakeKlantAdmin(string klantId)
        {
            var klant = _repositoryKlant.GetKlantByID(klantId);

            if (klant == null)
            {
                return(null);
            }
            _repositoryKlant.DeleteKlant(klantId);

            var admin = _repositoryAdmin.GetAdminByID(klantId);

            if (admin != null)
            {
                return(null);
            }
            var newAdmin     = _adminMapper.MapToModel(klantId);
            var createdAdmin = _repositoryAdmin.CreateAdmin(newAdmin);

            try
            {
                _repositoryKlant.SaveChanges();
            }
            catch (DbUpdateException)
            {
                return(null);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }

            return(_adminMapper.MapToDTO(createdAdmin));
        }